File: std_io_copy.rs

package info (click to toggle)
rust-gio 0.20.9-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,628 kB
  • sloc: makefile: 35; xml: 11
file content (15 lines) | stat: -rw-r--r-- 511 bytes parent folder | download | duplicates (3)
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);
}