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::AsyncResult; 6 use crate::Cancellable; 7 use crate::InputStream; 8 use crate::OutputStreamSpliceFlags; 9 use glib::object::IsA; 10 use glib::translate::*; 11 use std::boxed::Box as Box_; 12 use std::fmt; 13 use std::mem; 14 use std::pin::Pin; 15 use std::ptr; 16 17 glib::wrapper! { 18 #[doc(alias = "GOutputStream")] 19 pub struct OutputStream(Object<ffi::GOutputStream, ffi::GOutputStreamClass>); 20 21 match fn { 22 type_ => || ffi::g_output_stream_get_type(), 23 } 24 } 25 26 pub const NONE_OUTPUT_STREAM: Option<&OutputStream> = None; 27 28 pub trait OutputStreamExt: 'static { 29 #[doc(alias = "g_output_stream_clear_pending")] clear_pending(&self)30 fn clear_pending(&self); 31 32 #[doc(alias = "g_output_stream_close")] close<P: IsA<Cancellable>>(&self, cancellable: Option<&P>) -> Result<(), glib::Error>33 fn close<P: IsA<Cancellable>>(&self, cancellable: Option<&P>) -> Result<(), glib::Error>; 34 35 #[doc(alias = "g_output_stream_close_async")] close_async<P: IsA<Cancellable>, Q: FnOnce(Result<(), glib::Error>) + Send + 'static>( &self, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, )36 fn close_async<P: IsA<Cancellable>, Q: FnOnce(Result<(), glib::Error>) + Send + 'static>( 37 &self, 38 io_priority: glib::Priority, 39 cancellable: Option<&P>, 40 callback: Q, 41 ); 42 close_async_future( &self, io_priority: glib::Priority, ) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>>43 fn close_async_future( 44 &self, 45 io_priority: glib::Priority, 46 ) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>>; 47 48 #[doc(alias = "g_output_stream_flush")] flush<P: IsA<Cancellable>>(&self, cancellable: Option<&P>) -> Result<(), glib::Error>49 fn flush<P: IsA<Cancellable>>(&self, cancellable: Option<&P>) -> Result<(), glib::Error>; 50 51 #[doc(alias = "g_output_stream_flush_async")] flush_async<P: IsA<Cancellable>, Q: FnOnce(Result<(), glib::Error>) + Send + 'static>( &self, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, )52 fn flush_async<P: IsA<Cancellable>, Q: FnOnce(Result<(), glib::Error>) + Send + 'static>( 53 &self, 54 io_priority: glib::Priority, 55 cancellable: Option<&P>, 56 callback: Q, 57 ); 58 flush_async_future( &self, io_priority: glib::Priority, ) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>>59 fn flush_async_future( 60 &self, 61 io_priority: glib::Priority, 62 ) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>>; 63 64 #[doc(alias = "g_output_stream_has_pending")] has_pending(&self) -> bool65 fn has_pending(&self) -> bool; 66 67 #[doc(alias = "g_output_stream_is_closed")] is_closed(&self) -> bool68 fn is_closed(&self) -> bool; 69 70 #[doc(alias = "g_output_stream_is_closing")] is_closing(&self) -> bool71 fn is_closing(&self) -> bool; 72 73 //#[doc(alias = "g_output_stream_printf")] 74 //fn printf<P: IsA<Cancellable>>(&self, cancellable: Option<&P>, error: &mut glib::Error, format: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> Option<usize>; 75 76 #[doc(alias = "g_output_stream_set_pending")] set_pending(&self) -> Result<(), glib::Error>77 fn set_pending(&self) -> Result<(), glib::Error>; 78 79 #[doc(alias = "g_output_stream_splice")] splice<P: IsA<InputStream>, Q: IsA<Cancellable>>( &self, source: &P, flags: OutputStreamSpliceFlags, cancellable: Option<&Q>, ) -> Result<isize, glib::Error>80 fn splice<P: IsA<InputStream>, Q: IsA<Cancellable>>( 81 &self, 82 source: &P, 83 flags: OutputStreamSpliceFlags, 84 cancellable: Option<&Q>, 85 ) -> Result<isize, glib::Error>; 86 87 #[doc(alias = "g_output_stream_splice_async")] splice_async< P: IsA<InputStream>, Q: IsA<Cancellable>, R: FnOnce(Result<isize, glib::Error>) + Send + 'static, >( &self, source: &P, flags: OutputStreamSpliceFlags, io_priority: glib::Priority, cancellable: Option<&Q>, callback: R, )88 fn splice_async< 89 P: IsA<InputStream>, 90 Q: IsA<Cancellable>, 91 R: FnOnce(Result<isize, glib::Error>) + Send + 'static, 92 >( 93 &self, 94 source: &P, 95 flags: OutputStreamSpliceFlags, 96 io_priority: glib::Priority, 97 cancellable: Option<&Q>, 98 callback: R, 99 ); 100 splice_async_future<P: IsA<InputStream> + Clone + 'static>( &self, source: &P, flags: OutputStreamSpliceFlags, io_priority: glib::Priority, ) -> Pin<Box_<dyn std::future::Future<Output = Result<isize, glib::Error>> + 'static>>101 fn splice_async_future<P: IsA<InputStream> + Clone + 'static>( 102 &self, 103 source: &P, 104 flags: OutputStreamSpliceFlags, 105 io_priority: glib::Priority, 106 ) -> Pin<Box_<dyn std::future::Future<Output = Result<isize, glib::Error>> + 'static>>; 107 108 //#[doc(alias = "g_output_stream_vprintf")] 109 //fn vprintf<P: IsA<Cancellable>>(&self, cancellable: Option<&P>, error: &mut glib::Error, format: &str, args: /*Unknown conversion*//*Unimplemented*/Unsupported) -> Option<usize>; 110 111 #[doc(alias = "g_output_stream_write")] write<P: IsA<Cancellable>>( &self, buffer: &[u8], cancellable: Option<&P>, ) -> Result<isize, glib::Error>112 fn write<P: IsA<Cancellable>>( 113 &self, 114 buffer: &[u8], 115 cancellable: Option<&P>, 116 ) -> Result<isize, glib::Error>; 117 118 #[doc(alias = "g_output_stream_write_bytes")] write_bytes<P: IsA<Cancellable>>( &self, bytes: &glib::Bytes, cancellable: Option<&P>, ) -> Result<isize, glib::Error>119 fn write_bytes<P: IsA<Cancellable>>( 120 &self, 121 bytes: &glib::Bytes, 122 cancellable: Option<&P>, 123 ) -> Result<isize, glib::Error>; 124 125 #[doc(alias = "g_output_stream_write_bytes_async")] write_bytes_async< P: IsA<Cancellable>, Q: FnOnce(Result<isize, glib::Error>) + Send + 'static, >( &self, bytes: &glib::Bytes, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, )126 fn write_bytes_async< 127 P: IsA<Cancellable>, 128 Q: FnOnce(Result<isize, glib::Error>) + Send + 'static, 129 >( 130 &self, 131 bytes: &glib::Bytes, 132 io_priority: glib::Priority, 133 cancellable: Option<&P>, 134 callback: Q, 135 ); 136 write_bytes_async_future( &self, bytes: &glib::Bytes, io_priority: glib::Priority, ) -> Pin<Box_<dyn std::future::Future<Output = Result<isize, glib::Error>> + 'static>>137 fn write_bytes_async_future( 138 &self, 139 bytes: &glib::Bytes, 140 io_priority: glib::Priority, 141 ) -> Pin<Box_<dyn std::future::Future<Output = Result<isize, glib::Error>> + 'static>>; 142 143 //#[cfg(any(feature = "v2_60", feature = "dox"))] 144 //#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] 145 //#[doc(alias = "g_output_stream_writev")] 146 //fn writev<P: IsA<Cancellable>>(&self, vectors: /*Ignored*/&[&OutputVector], cancellable: Option<&P>) -> Result<usize, glib::Error>; 147 148 //#[cfg(any(feature = "v2_60", feature = "dox"))] 149 //#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] 150 //#[doc(alias = "g_output_stream_writev_all")] 151 //fn writev_all<P: IsA<Cancellable>>(&self, vectors: /*Ignored*/&[&OutputVector], cancellable: Option<&P>) -> Result<usize, glib::Error>; 152 153 //#[cfg(any(feature = "v2_60", feature = "dox"))] 154 //#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] 155 //#[doc(alias = "g_output_stream_writev_all_async")] 156 //fn writev_all_async<P: IsA<Cancellable>, Q: FnOnce(Result<usize, glib::Error>) + Send + 'static>(&self, vectors: /*Ignored*/&[&OutputVector], io_priority: glib::Priority, cancellable: Option<&P>, callback: Q); 157 158 // 159 //#[cfg(any(feature = "v2_60", feature = "dox"))] 160 //#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] 161 //fn writev_all_async_future(&self, vectors: /*Ignored*/&[&OutputVector], io_priority: glib::Priority) -> Pin<Box_<dyn std::future::Future<Output = Result<usize, glib::Error>> + 'static>>; 162 163 //#[cfg(any(feature = "v2_60", feature = "dox"))] 164 //#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] 165 //#[doc(alias = "g_output_stream_writev_async")] 166 //fn writev_async<P: IsA<Cancellable>, Q: FnOnce(Result<usize, glib::Error>) + Send + 'static>(&self, vectors: /*Ignored*/&[&OutputVector], io_priority: glib::Priority, cancellable: Option<&P>, callback: Q); 167 168 // 169 //#[cfg(any(feature = "v2_60", feature = "dox"))] 170 //#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] 171 //fn writev_async_future(&self, vectors: /*Ignored*/&[&OutputVector], io_priority: glib::Priority) -> Pin<Box_<dyn std::future::Future<Output = Result<usize, glib::Error>> + 'static>>; 172 } 173 174 impl<O: IsA<OutputStream>> OutputStreamExt for O { clear_pending(&self)175 fn clear_pending(&self) { 176 unsafe { 177 ffi::g_output_stream_clear_pending(self.as_ref().to_glib_none().0); 178 } 179 } 180 close<P: IsA<Cancellable>>(&self, cancellable: Option<&P>) -> Result<(), glib::Error>181 fn close<P: IsA<Cancellable>>(&self, cancellable: Option<&P>) -> Result<(), glib::Error> { 182 unsafe { 183 let mut error = ptr::null_mut(); 184 let _ = ffi::g_output_stream_close( 185 self.as_ref().to_glib_none().0, 186 cancellable.map(|p| p.as_ref()).to_glib_none().0, 187 &mut error, 188 ); 189 if error.is_null() { 190 Ok(()) 191 } else { 192 Err(from_glib_full(error)) 193 } 194 } 195 } 196 close_async<P: IsA<Cancellable>, Q: FnOnce(Result<(), glib::Error>) + Send + 'static>( &self, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, )197 fn close_async<P: IsA<Cancellable>, Q: FnOnce(Result<(), glib::Error>) + Send + 'static>( 198 &self, 199 io_priority: glib::Priority, 200 cancellable: Option<&P>, 201 callback: Q, 202 ) { 203 let user_data: Box_<Q> = Box_::new(callback); 204 unsafe extern "C" fn close_async_trampoline< 205 Q: FnOnce(Result<(), glib::Error>) + Send + 'static, 206 >( 207 _source_object: *mut glib::gobject_ffi::GObject, 208 res: *mut crate::ffi::GAsyncResult, 209 user_data: glib::ffi::gpointer, 210 ) { 211 let mut error = ptr::null_mut(); 212 let _ = ffi::g_output_stream_close_finish(_source_object as *mut _, res, &mut error); 213 let result = if error.is_null() { 214 Ok(()) 215 } else { 216 Err(from_glib_full(error)) 217 }; 218 let callback: Box_<Q> = Box_::from_raw(user_data as *mut _); 219 callback(result); 220 } 221 let callback = close_async_trampoline::<Q>; 222 unsafe { 223 ffi::g_output_stream_close_async( 224 self.as_ref().to_glib_none().0, 225 io_priority.into_glib(), 226 cancellable.map(|p| p.as_ref()).to_glib_none().0, 227 Some(callback), 228 Box_::into_raw(user_data) as *mut _, 229 ); 230 } 231 } 232 close_async_future( &self, io_priority: glib::Priority, ) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>>233 fn close_async_future( 234 &self, 235 io_priority: glib::Priority, 236 ) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>> { 237 Box_::pin(crate::GioFuture::new( 238 self, 239 move |obj, cancellable, send| { 240 obj.close_async(io_priority, Some(cancellable), move |res| { 241 send.resolve(res); 242 }); 243 }, 244 )) 245 } 246 flush<P: IsA<Cancellable>>(&self, cancellable: Option<&P>) -> Result<(), glib::Error>247 fn flush<P: IsA<Cancellable>>(&self, cancellable: Option<&P>) -> Result<(), glib::Error> { 248 unsafe { 249 let mut error = ptr::null_mut(); 250 let _ = ffi::g_output_stream_flush( 251 self.as_ref().to_glib_none().0, 252 cancellable.map(|p| p.as_ref()).to_glib_none().0, 253 &mut error, 254 ); 255 if error.is_null() { 256 Ok(()) 257 } else { 258 Err(from_glib_full(error)) 259 } 260 } 261 } 262 flush_async<P: IsA<Cancellable>, Q: FnOnce(Result<(), glib::Error>) + Send + 'static>( &self, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, )263 fn flush_async<P: IsA<Cancellable>, Q: FnOnce(Result<(), glib::Error>) + Send + 'static>( 264 &self, 265 io_priority: glib::Priority, 266 cancellable: Option<&P>, 267 callback: Q, 268 ) { 269 let user_data: Box_<Q> = Box_::new(callback); 270 unsafe extern "C" fn flush_async_trampoline< 271 Q: FnOnce(Result<(), glib::Error>) + Send + 'static, 272 >( 273 _source_object: *mut glib::gobject_ffi::GObject, 274 res: *mut crate::ffi::GAsyncResult, 275 user_data: glib::ffi::gpointer, 276 ) { 277 let mut error = ptr::null_mut(); 278 let _ = ffi::g_output_stream_flush_finish(_source_object as *mut _, res, &mut error); 279 let result = if error.is_null() { 280 Ok(()) 281 } else { 282 Err(from_glib_full(error)) 283 }; 284 let callback: Box_<Q> = Box_::from_raw(user_data as *mut _); 285 callback(result); 286 } 287 let callback = flush_async_trampoline::<Q>; 288 unsafe { 289 ffi::g_output_stream_flush_async( 290 self.as_ref().to_glib_none().0, 291 io_priority.into_glib(), 292 cancellable.map(|p| p.as_ref()).to_glib_none().0, 293 Some(callback), 294 Box_::into_raw(user_data) as *mut _, 295 ); 296 } 297 } 298 flush_async_future( &self, io_priority: glib::Priority, ) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>>299 fn flush_async_future( 300 &self, 301 io_priority: glib::Priority, 302 ) -> Pin<Box_<dyn std::future::Future<Output = Result<(), glib::Error>> + 'static>> { 303 Box_::pin(crate::GioFuture::new( 304 self, 305 move |obj, cancellable, send| { 306 obj.flush_async(io_priority, Some(cancellable), move |res| { 307 send.resolve(res); 308 }); 309 }, 310 )) 311 } 312 has_pending(&self) -> bool313 fn has_pending(&self) -> bool { 314 unsafe { 315 from_glib(ffi::g_output_stream_has_pending( 316 self.as_ref().to_glib_none().0, 317 )) 318 } 319 } 320 is_closed(&self) -> bool321 fn is_closed(&self) -> bool { 322 unsafe { 323 from_glib(ffi::g_output_stream_is_closed( 324 self.as_ref().to_glib_none().0, 325 )) 326 } 327 } 328 is_closing(&self) -> bool329 fn is_closing(&self) -> bool { 330 unsafe { 331 from_glib(ffi::g_output_stream_is_closing( 332 self.as_ref().to_glib_none().0, 333 )) 334 } 335 } 336 337 //fn printf<P: IsA<Cancellable>>(&self, cancellable: Option<&P>, error: &mut glib::Error, format: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> Option<usize> { 338 // unsafe { TODO: call ffi:g_output_stream_printf() } 339 //} 340 set_pending(&self) -> Result<(), glib::Error>341 fn set_pending(&self) -> Result<(), glib::Error> { 342 unsafe { 343 let mut error = ptr::null_mut(); 344 let _ = ffi::g_output_stream_set_pending(self.as_ref().to_glib_none().0, &mut error); 345 if error.is_null() { 346 Ok(()) 347 } else { 348 Err(from_glib_full(error)) 349 } 350 } 351 } 352 splice<P: IsA<InputStream>, Q: IsA<Cancellable>>( &self, source: &P, flags: OutputStreamSpliceFlags, cancellable: Option<&Q>, ) -> Result<isize, glib::Error>353 fn splice<P: IsA<InputStream>, Q: IsA<Cancellable>>( 354 &self, 355 source: &P, 356 flags: OutputStreamSpliceFlags, 357 cancellable: Option<&Q>, 358 ) -> Result<isize, glib::Error> { 359 unsafe { 360 let mut error = ptr::null_mut(); 361 let ret = ffi::g_output_stream_splice( 362 self.as_ref().to_glib_none().0, 363 source.as_ref().to_glib_none().0, 364 flags.into_glib(), 365 cancellable.map(|p| p.as_ref()).to_glib_none().0, 366 &mut error, 367 ); 368 if error.is_null() { 369 Ok(ret) 370 } else { 371 Err(from_glib_full(error)) 372 } 373 } 374 } 375 splice_async< P: IsA<InputStream>, Q: IsA<Cancellable>, R: FnOnce(Result<isize, glib::Error>) + Send + 'static, >( &self, source: &P, flags: OutputStreamSpliceFlags, io_priority: glib::Priority, cancellable: Option<&Q>, callback: R, )376 fn splice_async< 377 P: IsA<InputStream>, 378 Q: IsA<Cancellable>, 379 R: FnOnce(Result<isize, glib::Error>) + Send + 'static, 380 >( 381 &self, 382 source: &P, 383 flags: OutputStreamSpliceFlags, 384 io_priority: glib::Priority, 385 cancellable: Option<&Q>, 386 callback: R, 387 ) { 388 let user_data: Box_<R> = Box_::new(callback); 389 unsafe extern "C" fn splice_async_trampoline< 390 R: FnOnce(Result<isize, glib::Error>) + Send + 'static, 391 >( 392 _source_object: *mut glib::gobject_ffi::GObject, 393 res: *mut crate::ffi::GAsyncResult, 394 user_data: glib::ffi::gpointer, 395 ) { 396 let mut error = ptr::null_mut(); 397 let ret = ffi::g_output_stream_splice_finish(_source_object as *mut _, res, &mut error); 398 let result = if error.is_null() { 399 Ok(ret) 400 } else { 401 Err(from_glib_full(error)) 402 }; 403 let callback: Box_<R> = Box_::from_raw(user_data as *mut _); 404 callback(result); 405 } 406 let callback = splice_async_trampoline::<R>; 407 unsafe { 408 ffi::g_output_stream_splice_async( 409 self.as_ref().to_glib_none().0, 410 source.as_ref().to_glib_none().0, 411 flags.into_glib(), 412 io_priority.into_glib(), 413 cancellable.map(|p| p.as_ref()).to_glib_none().0, 414 Some(callback), 415 Box_::into_raw(user_data) as *mut _, 416 ); 417 } 418 } 419 splice_async_future<P: IsA<InputStream> + Clone + 'static>( &self, source: &P, flags: OutputStreamSpliceFlags, io_priority: glib::Priority, ) -> Pin<Box_<dyn std::future::Future<Output = Result<isize, glib::Error>> + 'static>>420 fn splice_async_future<P: IsA<InputStream> + Clone + 'static>( 421 &self, 422 source: &P, 423 flags: OutputStreamSpliceFlags, 424 io_priority: glib::Priority, 425 ) -> Pin<Box_<dyn std::future::Future<Output = Result<isize, glib::Error>> + 'static>> { 426 let source = source.clone(); 427 Box_::pin(crate::GioFuture::new( 428 self, 429 move |obj, cancellable, send| { 430 obj.splice_async(&source, flags, io_priority, Some(cancellable), move |res| { 431 send.resolve(res); 432 }); 433 }, 434 )) 435 } 436 437 //fn vprintf<P: IsA<Cancellable>>(&self, cancellable: Option<&P>, error: &mut glib::Error, format: &str, args: /*Unknown conversion*//*Unimplemented*/Unsupported) -> Option<usize> { 438 // unsafe { TODO: call ffi:g_output_stream_vprintf() } 439 //} 440 write<P: IsA<Cancellable>>( &self, buffer: &[u8], cancellable: Option<&P>, ) -> Result<isize, glib::Error>441 fn write<P: IsA<Cancellable>>( 442 &self, 443 buffer: &[u8], 444 cancellable: Option<&P>, 445 ) -> Result<isize, glib::Error> { 446 let count = buffer.len() as usize; 447 unsafe { 448 let mut error = ptr::null_mut(); 449 let ret = ffi::g_output_stream_write( 450 self.as_ref().to_glib_none().0, 451 buffer.to_glib_none().0, 452 count, 453 cancellable.map(|p| p.as_ref()).to_glib_none().0, 454 &mut error, 455 ); 456 if error.is_null() { 457 Ok(ret) 458 } else { 459 Err(from_glib_full(error)) 460 } 461 } 462 } 463 write_bytes<P: IsA<Cancellable>>( &self, bytes: &glib::Bytes, cancellable: Option<&P>, ) -> Result<isize, glib::Error>464 fn write_bytes<P: IsA<Cancellable>>( 465 &self, 466 bytes: &glib::Bytes, 467 cancellable: Option<&P>, 468 ) -> Result<isize, glib::Error> { 469 unsafe { 470 let mut error = ptr::null_mut(); 471 let ret = ffi::g_output_stream_write_bytes( 472 self.as_ref().to_glib_none().0, 473 bytes.to_glib_none().0, 474 cancellable.map(|p| p.as_ref()).to_glib_none().0, 475 &mut error, 476 ); 477 if error.is_null() { 478 Ok(ret) 479 } else { 480 Err(from_glib_full(error)) 481 } 482 } 483 } 484 write_bytes_async< P: IsA<Cancellable>, Q: FnOnce(Result<isize, glib::Error>) + Send + 'static, >( &self, bytes: &glib::Bytes, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, )485 fn write_bytes_async< 486 P: IsA<Cancellable>, 487 Q: FnOnce(Result<isize, glib::Error>) + Send + 'static, 488 >( 489 &self, 490 bytes: &glib::Bytes, 491 io_priority: glib::Priority, 492 cancellable: Option<&P>, 493 callback: Q, 494 ) { 495 let user_data: Box_<Q> = Box_::new(callback); 496 unsafe extern "C" fn write_bytes_async_trampoline< 497 Q: FnOnce(Result<isize, glib::Error>) + Send + 'static, 498 >( 499 _source_object: *mut glib::gobject_ffi::GObject, 500 res: *mut crate::ffi::GAsyncResult, 501 user_data: glib::ffi::gpointer, 502 ) { 503 let mut error = ptr::null_mut(); 504 let ret = 505 ffi::g_output_stream_write_bytes_finish(_source_object as *mut _, res, &mut error); 506 let result = if error.is_null() { 507 Ok(ret) 508 } else { 509 Err(from_glib_full(error)) 510 }; 511 let callback: Box_<Q> = Box_::from_raw(user_data as *mut _); 512 callback(result); 513 } 514 let callback = write_bytes_async_trampoline::<Q>; 515 unsafe { 516 ffi::g_output_stream_write_bytes_async( 517 self.as_ref().to_glib_none().0, 518 bytes.to_glib_none().0, 519 io_priority.into_glib(), 520 cancellable.map(|p| p.as_ref()).to_glib_none().0, 521 Some(callback), 522 Box_::into_raw(user_data) as *mut _, 523 ); 524 } 525 } 526 write_bytes_async_future( &self, bytes: &glib::Bytes, io_priority: glib::Priority, ) -> Pin<Box_<dyn std::future::Future<Output = Result<isize, glib::Error>> + 'static>>527 fn write_bytes_async_future( 528 &self, 529 bytes: &glib::Bytes, 530 io_priority: glib::Priority, 531 ) -> Pin<Box_<dyn std::future::Future<Output = Result<isize, glib::Error>> + 'static>> { 532 let bytes = bytes.clone(); 533 Box_::pin(crate::GioFuture::new( 534 self, 535 move |obj, cancellable, send| { 536 obj.write_bytes_async(&bytes, io_priority, Some(cancellable), move |res| { 537 send.resolve(res); 538 }); 539 }, 540 )) 541 } 542 543 //#[cfg(any(feature = "v2_60", feature = "dox"))] 544 //#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] 545 //fn writev<P: IsA<Cancellable>>(&self, vectors: /*Ignored*/&[&OutputVector], cancellable: Option<&P>) -> Result<usize, glib::Error> { 546 // unsafe { TODO: call ffi:g_output_stream_writev() } 547 //} 548 549 //#[cfg(any(feature = "v2_60", feature = "dox"))] 550 //#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] 551 //fn writev_all<P: IsA<Cancellable>>(&self, vectors: /*Ignored*/&[&OutputVector], cancellable: Option<&P>) -> Result<usize, glib::Error> { 552 // unsafe { TODO: call ffi:g_output_stream_writev_all() } 553 //} 554 555 //#[cfg(any(feature = "v2_60", feature = "dox"))] 556 //#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] 557 //fn writev_all_async<P: IsA<Cancellable>, Q: FnOnce(Result<usize, glib::Error>) + Send + 'static>(&self, vectors: /*Ignored*/&[&OutputVector], io_priority: glib::Priority, cancellable: Option<&P>, callback: Q) { 558 // unsafe { TODO: call ffi:g_output_stream_writev_all_async() } 559 //} 560 561 // 562 //#[cfg(any(feature = "v2_60", feature = "dox"))] 563 //#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] 564 //fn writev_all_async_future(&self, vectors: /*Ignored*/&[&OutputVector], io_priority: glib::Priority) -> Pin<Box_<dyn std::future::Future<Output = Result<usize, glib::Error>> + 'static>> { 565 566 //let vectors = vectors.clone(); 567 //Box_::pin(crate::GioFuture::new(self, move |obj, cancellable, send| { 568 // obj.writev_all_async( 569 // &vectors, 570 // io_priority, 571 // Some(cancellable), 572 // move |res| { 573 // send.resolve(res); 574 // }, 575 // ); 576 //})) 577 //} 578 579 //#[cfg(any(feature = "v2_60", feature = "dox"))] 580 //#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] 581 //fn writev_async<P: IsA<Cancellable>, Q: FnOnce(Result<usize, glib::Error>) + Send + 'static>(&self, vectors: /*Ignored*/&[&OutputVector], io_priority: glib::Priority, cancellable: Option<&P>, callback: Q) { 582 // unsafe { TODO: call ffi:g_output_stream_writev_async() } 583 //} 584 585 // 586 //#[cfg(any(feature = "v2_60", feature = "dox"))] 587 //#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] 588 //fn writev_async_future(&self, vectors: /*Ignored*/&[&OutputVector], io_priority: glib::Priority) -> Pin<Box_<dyn std::future::Future<Output = Result<usize, glib::Error>> + 'static>> { 589 590 //let vectors = vectors.clone(); 591 //Box_::pin(crate::GioFuture::new(self, move |obj, cancellable, send| { 592 // obj.writev_async( 593 // &vectors, 594 // io_priority, 595 // Some(cancellable), 596 // move |res| { 597 // send.resolve(res); 598 // }, 599 // ); 600 //})) 601 //} 602 } 603 604 impl fmt::Display for OutputStream { fmt(&self, f: &mut fmt::Formatter) -> fmt::Result605 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 606 f.write_str("OutputStream") 607 } 608 } 609