1 // This file was generated by gir (https://github.com/gtk-rs/gir)
2 // from gir-files (https://github.com/gtk-rs/gir-files)
3 // DO NOT EDIT
4 
5 use gio_sys;
6 use glib;
7 use glib::object::Cast;
8 use glib::object::IsA;
9 use glib::signal::connect_raw;
10 use glib::signal::SignalHandlerId;
11 use glib::translate::*;
12 use glib::GString;
13 use glib::StaticType;
14 use glib::ToValue;
15 use glib_sys;
16 use gobject_sys;
17 use std::boxed::Box as Box_;
18 use std::fmt;
19 use std::mem;
20 use std::mem::transmute;
21 use std::pin::Pin;
22 use std::ptr;
23 use BufferedInputStream;
24 use Cancellable;
25 use DataStreamByteOrder;
26 use DataStreamNewlineType;
27 use FilterInputStream;
28 use InputStream;
29 use Seekable;
30 
31 glib_wrapper! {
32     pub struct DataInputStream(Object<gio_sys::GDataInputStream, gio_sys::GDataInputStreamClass, DataInputStreamClass>) @extends BufferedInputStream, FilterInputStream, InputStream, @implements Seekable;
33 
34     match fn {
35         get_type => || gio_sys::g_data_input_stream_get_type(),
36     }
37 }
38 
39 impl DataInputStream {
new<P: IsA<InputStream>>(base_stream: &P) -> DataInputStream40     pub fn new<P: IsA<InputStream>>(base_stream: &P) -> DataInputStream {
41         unsafe {
42             from_glib_full(gio_sys::g_data_input_stream_new(
43                 base_stream.as_ref().to_glib_none().0,
44             ))
45         }
46     }
47 }
48 
49 #[derive(Clone, Default)]
50 pub struct DataInputStreamBuilder {
51     byte_order: Option<DataStreamByteOrder>,
52     newline_type: Option<DataStreamNewlineType>,
53     buffer_size: Option<u32>,
54     base_stream: Option<InputStream>,
55     close_base_stream: Option<bool>,
56 }
57 
58 impl DataInputStreamBuilder {
new() -> Self59     pub fn new() -> Self {
60         Self::default()
61     }
62 
build(self) -> DataInputStream63     pub fn build(self) -> DataInputStream {
64         let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
65         if let Some(ref byte_order) = self.byte_order {
66             properties.push(("byte-order", byte_order));
67         }
68         if let Some(ref newline_type) = self.newline_type {
69             properties.push(("newline-type", newline_type));
70         }
71         if let Some(ref buffer_size) = self.buffer_size {
72             properties.push(("buffer-size", buffer_size));
73         }
74         if let Some(ref base_stream) = self.base_stream {
75             properties.push(("base-stream", base_stream));
76         }
77         if let Some(ref close_base_stream) = self.close_base_stream {
78             properties.push(("close-base-stream", close_base_stream));
79         }
80         glib::Object::new(DataInputStream::static_type(), &properties)
81             .expect("object new")
82             .downcast()
83             .expect("downcast")
84     }
85 
byte_order(mut self, byte_order: DataStreamByteOrder) -> Self86     pub fn byte_order(mut self, byte_order: DataStreamByteOrder) -> Self {
87         self.byte_order = Some(byte_order);
88         self
89     }
90 
newline_type(mut self, newline_type: DataStreamNewlineType) -> Self91     pub fn newline_type(mut self, newline_type: DataStreamNewlineType) -> Self {
92         self.newline_type = Some(newline_type);
93         self
94     }
95 
buffer_size(mut self, buffer_size: u32) -> Self96     pub fn buffer_size(mut self, buffer_size: u32) -> Self {
97         self.buffer_size = Some(buffer_size);
98         self
99     }
100 
base_stream<P: IsA<InputStream>>(mut self, base_stream: &P) -> Self101     pub fn base_stream<P: IsA<InputStream>>(mut self, base_stream: &P) -> Self {
102         self.base_stream = Some(base_stream.clone().upcast());
103         self
104     }
105 
close_base_stream(mut self, close_base_stream: bool) -> Self106     pub fn close_base_stream(mut self, close_base_stream: bool) -> Self {
107         self.close_base_stream = Some(close_base_stream);
108         self
109     }
110 }
111 
112 pub const NONE_DATA_INPUT_STREAM: Option<&DataInputStream> = None;
113 
114 pub trait DataInputStreamExt: 'static {
get_byte_order(&self) -> DataStreamByteOrder115     fn get_byte_order(&self) -> DataStreamByteOrder;
116 
get_newline_type(&self) -> DataStreamNewlineType117     fn get_newline_type(&self) -> DataStreamNewlineType;
118 
read_byte<P: IsA<Cancellable>>(&self, cancellable: Option<&P>) -> Result<u8, glib::Error>119     fn read_byte<P: IsA<Cancellable>>(&self, cancellable: Option<&P>) -> Result<u8, glib::Error>;
120 
read_int16<P: IsA<Cancellable>>(&self, cancellable: Option<&P>) -> Result<i16, glib::Error>121     fn read_int16<P: IsA<Cancellable>>(&self, cancellable: Option<&P>) -> Result<i16, glib::Error>;
122 
read_int32<P: IsA<Cancellable>>(&self, cancellable: Option<&P>) -> Result<i32, glib::Error>123     fn read_int32<P: IsA<Cancellable>>(&self, cancellable: Option<&P>) -> Result<i32, glib::Error>;
124 
read_int64<P: IsA<Cancellable>>(&self, cancellable: Option<&P>) -> Result<i64, glib::Error>125     fn read_int64<P: IsA<Cancellable>>(&self, cancellable: Option<&P>) -> Result<i64, glib::Error>;
126 
127     //fn read_line_finish_utf8(&self, result: /*Ignored*/&AsyncResult) -> Result<(Option<GString>, usize), glib::Error>;
128 
read_line_utf8<P: IsA<Cancellable>>( &self, cancellable: Option<&P>, ) -> Result<(Option<GString>, usize), glib::Error>129     fn read_line_utf8<P: IsA<Cancellable>>(
130         &self,
131         cancellable: Option<&P>,
132     ) -> Result<(Option<GString>, usize), glib::Error>;
133 
read_uint16<P: IsA<Cancellable>>(&self, cancellable: Option<&P>) -> Result<u16, glib::Error>134     fn read_uint16<P: IsA<Cancellable>>(&self, cancellable: Option<&P>)
135         -> Result<u16, glib::Error>;
136 
read_uint32<P: IsA<Cancellable>>(&self, cancellable: Option<&P>) -> Result<u32, glib::Error>137     fn read_uint32<P: IsA<Cancellable>>(&self, cancellable: Option<&P>)
138         -> Result<u32, glib::Error>;
139 
read_uint64<P: IsA<Cancellable>>(&self, cancellable: Option<&P>) -> Result<u64, glib::Error>140     fn read_uint64<P: IsA<Cancellable>>(&self, cancellable: Option<&P>)
141         -> Result<u64, glib::Error>;
142 
143     #[cfg_attr(feature = "v2_56", deprecated)]
read_until<P: IsA<Cancellable>>( &self, stop_chars: &str, cancellable: Option<&P>, ) -> Result<(GString, usize), glib::Error>144     fn read_until<P: IsA<Cancellable>>(
145         &self,
146         stop_chars: &str,
147         cancellable: Option<&P>,
148     ) -> Result<(GString, usize), glib::Error>;
149 
150     #[cfg_attr(feature = "v2_56", deprecated)]
read_until_async< P: IsA<Cancellable>, Q: FnOnce(Result<(GString, usize), glib::Error>) + Send + 'static, >( &self, stop_chars: &str, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, )151     fn read_until_async<
152         P: IsA<Cancellable>,
153         Q: FnOnce(Result<(GString, usize), glib::Error>) + Send + 'static,
154     >(
155         &self,
156         stop_chars: &str,
157         io_priority: glib::Priority,
158         cancellable: Option<&P>,
159         callback: Q,
160     );
161 
162     #[cfg_attr(feature = "v2_56", deprecated)]
163 
read_until_async_future( &self, stop_chars: &str, io_priority: glib::Priority, ) -> Pin<Box_<dyn std::future::Future<Output = Result<(GString, usize), glib::Error>> + 'static>>164     fn read_until_async_future(
165         &self,
166         stop_chars: &str,
167         io_priority: glib::Priority,
168     ) -> Pin<Box_<dyn std::future::Future<Output = Result<(GString, usize), glib::Error>> + 'static>>;
169 
read_upto<P: IsA<Cancellable>>( &self, stop_chars: &str, cancellable: Option<&P>, ) -> Result<(GString, usize), glib::Error>170     fn read_upto<P: IsA<Cancellable>>(
171         &self,
172         stop_chars: &str,
173         cancellable: Option<&P>,
174     ) -> Result<(GString, usize), glib::Error>;
175 
read_upto_async< P: IsA<Cancellable>, Q: FnOnce(Result<(GString, usize), glib::Error>) + Send + 'static, >( &self, stop_chars: &str, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, )176     fn read_upto_async<
177         P: IsA<Cancellable>,
178         Q: FnOnce(Result<(GString, usize), glib::Error>) + Send + 'static,
179     >(
180         &self,
181         stop_chars: &str,
182         io_priority: glib::Priority,
183         cancellable: Option<&P>,
184         callback: Q,
185     );
186 
read_upto_async_future( &self, stop_chars: &str, io_priority: glib::Priority, ) -> Pin<Box_<dyn std::future::Future<Output = Result<(GString, usize), glib::Error>> + 'static>>187     fn read_upto_async_future(
188         &self,
189         stop_chars: &str,
190         io_priority: glib::Priority,
191     ) -> Pin<Box_<dyn std::future::Future<Output = Result<(GString, usize), glib::Error>> + 'static>>;
192 
set_byte_order(&self, order: DataStreamByteOrder)193     fn set_byte_order(&self, order: DataStreamByteOrder);
194 
set_newline_type(&self, type_: DataStreamNewlineType)195     fn set_newline_type(&self, type_: DataStreamNewlineType);
196 
connect_property_byte_order_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId197     fn connect_property_byte_order_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
198 
connect_property_newline_type_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId199     fn connect_property_newline_type_notify<F: Fn(&Self) + 'static>(&self, f: F)
200         -> SignalHandlerId;
201 }
202 
203 impl<O: IsA<DataInputStream>> DataInputStreamExt for O {
get_byte_order(&self) -> DataStreamByteOrder204     fn get_byte_order(&self) -> DataStreamByteOrder {
205         unsafe {
206             from_glib(gio_sys::g_data_input_stream_get_byte_order(
207                 self.as_ref().to_glib_none().0,
208             ))
209         }
210     }
211 
get_newline_type(&self) -> DataStreamNewlineType212     fn get_newline_type(&self) -> DataStreamNewlineType {
213         unsafe {
214             from_glib(gio_sys::g_data_input_stream_get_newline_type(
215                 self.as_ref().to_glib_none().0,
216             ))
217         }
218     }
219 
read_byte<P: IsA<Cancellable>>(&self, cancellable: Option<&P>) -> Result<u8, glib::Error>220     fn read_byte<P: IsA<Cancellable>>(&self, cancellable: Option<&P>) -> Result<u8, glib::Error> {
221         unsafe {
222             let mut error = ptr::null_mut();
223             let ret = gio_sys::g_data_input_stream_read_byte(
224                 self.as_ref().to_glib_none().0,
225                 cancellable.map(|p| p.as_ref()).to_glib_none().0,
226                 &mut error,
227             );
228             if error.is_null() {
229                 Ok(ret)
230             } else {
231                 Err(from_glib_full(error))
232             }
233         }
234     }
235 
read_int16<P: IsA<Cancellable>>(&self, cancellable: Option<&P>) -> Result<i16, glib::Error>236     fn read_int16<P: IsA<Cancellable>>(&self, cancellable: Option<&P>) -> Result<i16, glib::Error> {
237         unsafe {
238             let mut error = ptr::null_mut();
239             let ret = gio_sys::g_data_input_stream_read_int16(
240                 self.as_ref().to_glib_none().0,
241                 cancellable.map(|p| p.as_ref()).to_glib_none().0,
242                 &mut error,
243             );
244             if error.is_null() {
245                 Ok(ret)
246             } else {
247                 Err(from_glib_full(error))
248             }
249         }
250     }
251 
read_int32<P: IsA<Cancellable>>(&self, cancellable: Option<&P>) -> Result<i32, glib::Error>252     fn read_int32<P: IsA<Cancellable>>(&self, cancellable: Option<&P>) -> Result<i32, glib::Error> {
253         unsafe {
254             let mut error = ptr::null_mut();
255             let ret = gio_sys::g_data_input_stream_read_int32(
256                 self.as_ref().to_glib_none().0,
257                 cancellable.map(|p| p.as_ref()).to_glib_none().0,
258                 &mut error,
259             );
260             if error.is_null() {
261                 Ok(ret)
262             } else {
263                 Err(from_glib_full(error))
264             }
265         }
266     }
267 
read_int64<P: IsA<Cancellable>>(&self, cancellable: Option<&P>) -> Result<i64, glib::Error>268     fn read_int64<P: IsA<Cancellable>>(&self, cancellable: Option<&P>) -> Result<i64, glib::Error> {
269         unsafe {
270             let mut error = ptr::null_mut();
271             let ret = gio_sys::g_data_input_stream_read_int64(
272                 self.as_ref().to_glib_none().0,
273                 cancellable.map(|p| p.as_ref()).to_glib_none().0,
274                 &mut error,
275             );
276             if error.is_null() {
277                 Ok(ret)
278             } else {
279                 Err(from_glib_full(error))
280             }
281         }
282     }
283 
284     //fn read_line_finish_utf8(&self, result: /*Ignored*/&AsyncResult) -> Result<(Option<GString>, usize), glib::Error> {
285     //    unsafe { TODO: call gio_sys:g_data_input_stream_read_line_finish_utf8() }
286     //}
287 
read_line_utf8<P: IsA<Cancellable>>( &self, cancellable: Option<&P>, ) -> Result<(Option<GString>, usize), glib::Error>288     fn read_line_utf8<P: IsA<Cancellable>>(
289         &self,
290         cancellable: Option<&P>,
291     ) -> Result<(Option<GString>, usize), glib::Error> {
292         unsafe {
293             let mut length = mem::MaybeUninit::uninit();
294             let mut error = ptr::null_mut();
295             let ret = gio_sys::g_data_input_stream_read_line_utf8(
296                 self.as_ref().to_glib_none().0,
297                 length.as_mut_ptr(),
298                 cancellable.map(|p| p.as_ref()).to_glib_none().0,
299                 &mut error,
300             );
301             let length = length.assume_init();
302             if error.is_null() {
303                 Ok((from_glib_full(ret), length))
304             } else {
305                 Err(from_glib_full(error))
306             }
307         }
308     }
309 
read_uint16<P: IsA<Cancellable>>( &self, cancellable: Option<&P>, ) -> Result<u16, glib::Error>310     fn read_uint16<P: IsA<Cancellable>>(
311         &self,
312         cancellable: Option<&P>,
313     ) -> Result<u16, glib::Error> {
314         unsafe {
315             let mut error = ptr::null_mut();
316             let ret = gio_sys::g_data_input_stream_read_uint16(
317                 self.as_ref().to_glib_none().0,
318                 cancellable.map(|p| p.as_ref()).to_glib_none().0,
319                 &mut error,
320             );
321             if error.is_null() {
322                 Ok(ret)
323             } else {
324                 Err(from_glib_full(error))
325             }
326         }
327     }
328 
read_uint32<P: IsA<Cancellable>>( &self, cancellable: Option<&P>, ) -> Result<u32, glib::Error>329     fn read_uint32<P: IsA<Cancellable>>(
330         &self,
331         cancellable: Option<&P>,
332     ) -> Result<u32, glib::Error> {
333         unsafe {
334             let mut error = ptr::null_mut();
335             let ret = gio_sys::g_data_input_stream_read_uint32(
336                 self.as_ref().to_glib_none().0,
337                 cancellable.map(|p| p.as_ref()).to_glib_none().0,
338                 &mut error,
339             );
340             if error.is_null() {
341                 Ok(ret)
342             } else {
343                 Err(from_glib_full(error))
344             }
345         }
346     }
347 
read_uint64<P: IsA<Cancellable>>( &self, cancellable: Option<&P>, ) -> Result<u64, glib::Error>348     fn read_uint64<P: IsA<Cancellable>>(
349         &self,
350         cancellable: Option<&P>,
351     ) -> Result<u64, glib::Error> {
352         unsafe {
353             let mut error = ptr::null_mut();
354             let ret = gio_sys::g_data_input_stream_read_uint64(
355                 self.as_ref().to_glib_none().0,
356                 cancellable.map(|p| p.as_ref()).to_glib_none().0,
357                 &mut error,
358             );
359             if error.is_null() {
360                 Ok(ret)
361             } else {
362                 Err(from_glib_full(error))
363             }
364         }
365     }
366 
read_until<P: IsA<Cancellable>>( &self, stop_chars: &str, cancellable: Option<&P>, ) -> Result<(GString, usize), glib::Error>367     fn read_until<P: IsA<Cancellable>>(
368         &self,
369         stop_chars: &str,
370         cancellable: Option<&P>,
371     ) -> Result<(GString, usize), glib::Error> {
372         unsafe {
373             let mut length = mem::MaybeUninit::uninit();
374             let mut error = ptr::null_mut();
375             let ret = gio_sys::g_data_input_stream_read_until(
376                 self.as_ref().to_glib_none().0,
377                 stop_chars.to_glib_none().0,
378                 length.as_mut_ptr(),
379                 cancellable.map(|p| p.as_ref()).to_glib_none().0,
380                 &mut error,
381             );
382             let length = length.assume_init();
383             if error.is_null() {
384                 Ok((from_glib_full(ret), length))
385             } else {
386                 Err(from_glib_full(error))
387             }
388         }
389     }
390 
read_until_async< P: IsA<Cancellable>, Q: FnOnce(Result<(GString, usize), glib::Error>) + Send + 'static, >( &self, stop_chars: &str, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, )391     fn read_until_async<
392         P: IsA<Cancellable>,
393         Q: FnOnce(Result<(GString, usize), glib::Error>) + Send + 'static,
394     >(
395         &self,
396         stop_chars: &str,
397         io_priority: glib::Priority,
398         cancellable: Option<&P>,
399         callback: Q,
400     ) {
401         let user_data: Box_<Q> = Box_::new(callback);
402         unsafe extern "C" fn read_until_async_trampoline<
403             Q: FnOnce(Result<(GString, usize), glib::Error>) + Send + 'static,
404         >(
405             _source_object: *mut gobject_sys::GObject,
406             res: *mut gio_sys::GAsyncResult,
407             user_data: glib_sys::gpointer,
408         ) {
409             let mut error = ptr::null_mut();
410             let mut length = mem::MaybeUninit::uninit();
411             let ret = gio_sys::g_data_input_stream_read_until_finish(
412                 _source_object as *mut _,
413                 res,
414                 length.as_mut_ptr(),
415                 &mut error,
416             );
417             let length = length.assume_init();
418             let result = if error.is_null() {
419                 Ok((from_glib_full(ret), length))
420             } else {
421                 Err(from_glib_full(error))
422             };
423             let callback: Box_<Q> = Box_::from_raw(user_data as *mut _);
424             callback(result);
425         }
426         let callback = read_until_async_trampoline::<Q>;
427         unsafe {
428             gio_sys::g_data_input_stream_read_until_async(
429                 self.as_ref().to_glib_none().0,
430                 stop_chars.to_glib_none().0,
431                 io_priority.to_glib(),
432                 cancellable.map(|p| p.as_ref()).to_glib_none().0,
433                 Some(callback),
434                 Box_::into_raw(user_data) as *mut _,
435             );
436         }
437     }
438 
read_until_async_future( &self, stop_chars: &str, io_priority: glib::Priority, ) -> Pin<Box_<dyn std::future::Future<Output = Result<(GString, usize), glib::Error>> + 'static>>439     fn read_until_async_future(
440         &self,
441         stop_chars: &str,
442         io_priority: glib::Priority,
443     ) -> Pin<Box_<dyn std::future::Future<Output = Result<(GString, usize), glib::Error>> + 'static>>
444     {
445         let stop_chars = String::from(stop_chars);
446         Box_::pin(crate::GioFuture::new(self, move |obj, send| {
447             let cancellable = Cancellable::new();
448             obj.read_until_async(&stop_chars, io_priority, Some(&cancellable), move |res| {
449                 send.resolve(res);
450             });
451 
452             cancellable
453         }))
454     }
455 
read_upto<P: IsA<Cancellable>>( &self, stop_chars: &str, cancellable: Option<&P>, ) -> Result<(GString, usize), glib::Error>456     fn read_upto<P: IsA<Cancellable>>(
457         &self,
458         stop_chars: &str,
459         cancellable: Option<&P>,
460     ) -> Result<(GString, usize), glib::Error> {
461         let stop_chars_len = stop_chars.len() as isize;
462         unsafe {
463             let mut length = mem::MaybeUninit::uninit();
464             let mut error = ptr::null_mut();
465             let ret = gio_sys::g_data_input_stream_read_upto(
466                 self.as_ref().to_glib_none().0,
467                 stop_chars.to_glib_none().0,
468                 stop_chars_len,
469                 length.as_mut_ptr(),
470                 cancellable.map(|p| p.as_ref()).to_glib_none().0,
471                 &mut error,
472             );
473             let length = length.assume_init();
474             if error.is_null() {
475                 Ok((from_glib_full(ret), length))
476             } else {
477                 Err(from_glib_full(error))
478             }
479         }
480     }
481 
read_upto_async< P: IsA<Cancellable>, Q: FnOnce(Result<(GString, usize), glib::Error>) + Send + 'static, >( &self, stop_chars: &str, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, )482     fn read_upto_async<
483         P: IsA<Cancellable>,
484         Q: FnOnce(Result<(GString, usize), glib::Error>) + Send + 'static,
485     >(
486         &self,
487         stop_chars: &str,
488         io_priority: glib::Priority,
489         cancellable: Option<&P>,
490         callback: Q,
491     ) {
492         let stop_chars_len = stop_chars.len() as isize;
493         let user_data: Box_<Q> = Box_::new(callback);
494         unsafe extern "C" fn read_upto_async_trampoline<
495             Q: FnOnce(Result<(GString, usize), glib::Error>) + Send + 'static,
496         >(
497             _source_object: *mut gobject_sys::GObject,
498             res: *mut gio_sys::GAsyncResult,
499             user_data: glib_sys::gpointer,
500         ) {
501             let mut error = ptr::null_mut();
502             let mut length = mem::MaybeUninit::uninit();
503             let ret = gio_sys::g_data_input_stream_read_upto_finish(
504                 _source_object as *mut _,
505                 res,
506                 length.as_mut_ptr(),
507                 &mut error,
508             );
509             let length = length.assume_init();
510             let result = if error.is_null() {
511                 Ok((from_glib_full(ret), length))
512             } else {
513                 Err(from_glib_full(error))
514             };
515             let callback: Box_<Q> = Box_::from_raw(user_data as *mut _);
516             callback(result);
517         }
518         let callback = read_upto_async_trampoline::<Q>;
519         unsafe {
520             gio_sys::g_data_input_stream_read_upto_async(
521                 self.as_ref().to_glib_none().0,
522                 stop_chars.to_glib_none().0,
523                 stop_chars_len,
524                 io_priority.to_glib(),
525                 cancellable.map(|p| p.as_ref()).to_glib_none().0,
526                 Some(callback),
527                 Box_::into_raw(user_data) as *mut _,
528             );
529         }
530     }
531 
read_upto_async_future( &self, stop_chars: &str, io_priority: glib::Priority, ) -> Pin<Box_<dyn std::future::Future<Output = Result<(GString, usize), glib::Error>> + 'static>>532     fn read_upto_async_future(
533         &self,
534         stop_chars: &str,
535         io_priority: glib::Priority,
536     ) -> Pin<Box_<dyn std::future::Future<Output = Result<(GString, usize), glib::Error>> + 'static>>
537     {
538         let stop_chars = String::from(stop_chars);
539         Box_::pin(crate::GioFuture::new(self, move |obj, send| {
540             let cancellable = Cancellable::new();
541             obj.read_upto_async(&stop_chars, io_priority, Some(&cancellable), move |res| {
542                 send.resolve(res);
543             });
544 
545             cancellable
546         }))
547     }
548 
set_byte_order(&self, order: DataStreamByteOrder)549     fn set_byte_order(&self, order: DataStreamByteOrder) {
550         unsafe {
551             gio_sys::g_data_input_stream_set_byte_order(
552                 self.as_ref().to_glib_none().0,
553                 order.to_glib(),
554             );
555         }
556     }
557 
set_newline_type(&self, type_: DataStreamNewlineType)558     fn set_newline_type(&self, type_: DataStreamNewlineType) {
559         unsafe {
560             gio_sys::g_data_input_stream_set_newline_type(
561                 self.as_ref().to_glib_none().0,
562                 type_.to_glib(),
563             );
564         }
565     }
566 
connect_property_byte_order_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId567     fn connect_property_byte_order_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
568         unsafe extern "C" fn notify_byte_order_trampoline<P, F: Fn(&P) + 'static>(
569             this: *mut gio_sys::GDataInputStream,
570             _param_spec: glib_sys::gpointer,
571             f: glib_sys::gpointer,
572         ) where
573             P: IsA<DataInputStream>,
574         {
575             let f: &F = &*(f as *const F);
576             f(&DataInputStream::from_glib_borrow(this).unsafe_cast())
577         }
578         unsafe {
579             let f: Box_<F> = Box_::new(f);
580             connect_raw(
581                 self.as_ptr() as *mut _,
582                 b"notify::byte-order\0".as_ptr() as *const _,
583                 Some(transmute(notify_byte_order_trampoline::<Self, F> as usize)),
584                 Box_::into_raw(f),
585             )
586         }
587     }
588 
connect_property_newline_type_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId589     fn connect_property_newline_type_notify<F: Fn(&Self) + 'static>(
590         &self,
591         f: F,
592     ) -> SignalHandlerId {
593         unsafe extern "C" fn notify_newline_type_trampoline<P, F: Fn(&P) + 'static>(
594             this: *mut gio_sys::GDataInputStream,
595             _param_spec: glib_sys::gpointer,
596             f: glib_sys::gpointer,
597         ) where
598             P: IsA<DataInputStream>,
599         {
600             let f: &F = &*(f as *const F);
601             f(&DataInputStream::from_glib_borrow(this).unsafe_cast())
602         }
603         unsafe {
604             let f: Box_<F> = Box_::new(f);
605             connect_raw(
606                 self.as_ptr() as *mut _,
607                 b"notify::newline-type\0".as_ptr() as *const _,
608                 Some(transmute(
609                     notify_newline_type_trampoline::<Self, F> as usize,
610                 )),
611                 Box_::into_raw(f),
612             )
613         }
614     }
615 }
616 
617 impl fmt::Display for DataInputStream {
fmt(&self, f: &mut fmt::Formatter) -> fmt::Result618     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
619         write!(f, "DataInputStream")
620     }
621 }
622