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 crate::Cancellable; 6 use crate::OutputStream; 7 use glib::object::IsA; 8 use glib::translate::*; 9 use std::fmt; 10 use std::ptr; 11 12 glib::wrapper! { 13 #[doc(alias = "GPollableOutputStream")] 14 pub struct PollableOutputStream(Interface<ffi::GPollableOutputStream, ffi::GPollableOutputStreamInterface>) @requires OutputStream; 15 16 match fn { 17 type_ => || ffi::g_pollable_output_stream_get_type(), 18 } 19 } 20 21 pub const NONE_POLLABLE_OUTPUT_STREAM: Option<&PollableOutputStream> = None; 22 23 pub trait PollableOutputStreamExt: 'static { 24 #[doc(alias = "g_pollable_output_stream_can_poll")] can_poll(&self) -> bool25 fn can_poll(&self) -> bool; 26 27 #[doc(alias = "g_pollable_output_stream_is_writable")] is_writable(&self) -> bool28 fn is_writable(&self) -> bool; 29 30 #[doc(alias = "g_pollable_output_stream_write_nonblocking")] write_nonblocking<P: IsA<Cancellable>>( &self, buffer: &[u8], cancellable: Option<&P>, ) -> Result<isize, glib::Error>31 fn write_nonblocking<P: IsA<Cancellable>>( 32 &self, 33 buffer: &[u8], 34 cancellable: Option<&P>, 35 ) -> Result<isize, glib::Error>; 36 37 //#[cfg(any(feature = "v2_60", feature = "dox"))] 38 //#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] 39 //#[doc(alias = "g_pollable_output_stream_writev_nonblocking")] 40 //fn writev_nonblocking<P: IsA<Cancellable>>(&self, vectors: /*Ignored*/&[&OutputVector], cancellable: Option<&P>) -> Result<(/*Ignored*/PollableReturn, usize), glib::Error>; 41 } 42 43 impl<O: IsA<PollableOutputStream>> PollableOutputStreamExt for O { can_poll(&self) -> bool44 fn can_poll(&self) -> bool { 45 unsafe { 46 from_glib(ffi::g_pollable_output_stream_can_poll( 47 self.as_ref().to_glib_none().0, 48 )) 49 } 50 } 51 is_writable(&self) -> bool52 fn is_writable(&self) -> bool { 53 unsafe { 54 from_glib(ffi::g_pollable_output_stream_is_writable( 55 self.as_ref().to_glib_none().0, 56 )) 57 } 58 } 59 write_nonblocking<P: IsA<Cancellable>>( &self, buffer: &[u8], cancellable: Option<&P>, ) -> Result<isize, glib::Error>60 fn write_nonblocking<P: IsA<Cancellable>>( 61 &self, 62 buffer: &[u8], 63 cancellable: Option<&P>, 64 ) -> Result<isize, glib::Error> { 65 let count = buffer.len() as usize; 66 unsafe { 67 let mut error = ptr::null_mut(); 68 let ret = ffi::g_pollable_output_stream_write_nonblocking( 69 self.as_ref().to_glib_none().0, 70 buffer.to_glib_none().0, 71 count, 72 cancellable.map(|p| p.as_ref()).to_glib_none().0, 73 &mut error, 74 ); 75 if error.is_null() { 76 Ok(ret) 77 } else { 78 Err(from_glib_full(error)) 79 } 80 } 81 } 82 83 //#[cfg(any(feature = "v2_60", feature = "dox"))] 84 //#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] 85 //fn writev_nonblocking<P: IsA<Cancellable>>(&self, vectors: /*Ignored*/&[&OutputVector], cancellable: Option<&P>) -> Result<(/*Ignored*/PollableReturn, usize), glib::Error> { 86 // unsafe { TODO: call ffi:g_pollable_output_stream_writev_nonblocking() } 87 //} 88 } 89 90 impl fmt::Display for PollableOutputStream { fmt(&self, f: &mut fmt::Formatter) -> fmt::Result91 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 92 f.write_str("PollableOutputStream") 93 } 94 } 95