gio 0.20.4

Rust bindings for the Gio library
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use gio::prelude::*;

#[test]
fn std_io_copy_with_gio() {
    let bytes = glib::Bytes::from_owned([1, 2, 3]);
    let mut read = gio::MemoryInputStream::from_bytes(&bytes).into_read();
    let mut write = gio::MemoryOutputStream::new_resizable().into_write();

    let result = std::io::copy(&mut read, &mut write);

    let out_stream = write.into_output_stream();
    out_stream.close(gio::Cancellable::NONE).unwrap();
    assert_eq!(result.unwrap(), 3);
    assert_eq!(out_stream.steal_as_bytes(), bytes);
}