gio/auto/
memory_input_stream.rs1use crate::{ffi, InputStream, PollableInputStream, Seekable};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9 #[doc(alias = "GMemoryInputStream")]
10 pub struct MemoryInputStream(Object<ffi::GMemoryInputStream, ffi::GMemoryInputStreamClass>) @extends InputStream, @implements PollableInputStream, Seekable;
11
12 match fn {
13 type_ => || ffi::g_memory_input_stream_get_type(),
14 }
15}
16
17impl MemoryInputStream {
18 pub const NONE: Option<&'static MemoryInputStream> = None;
19
20 #[doc(alias = "g_memory_input_stream_new")]
21 pub fn new() -> MemoryInputStream {
22 unsafe { InputStream::from_glib_full(ffi::g_memory_input_stream_new()).unsafe_cast() }
23 }
24
25 #[doc(alias = "g_memory_input_stream_new_from_bytes")]
26 #[doc(alias = "new_from_bytes")]
27 pub fn from_bytes(bytes: &glib::Bytes) -> MemoryInputStream {
28 unsafe {
29 InputStream::from_glib_full(ffi::g_memory_input_stream_new_from_bytes(
30 bytes.to_glib_none().0,
31 ))
32 .unsafe_cast()
33 }
34 }
35}
36
37impl Default for MemoryInputStream {
38 fn default() -> Self {
39 Self::new()
40 }
41}
42
43pub trait MemoryInputStreamExt: IsA<MemoryInputStream> + 'static {
44 #[doc(alias = "g_memory_input_stream_add_bytes")]
45 fn add_bytes(&self, bytes: &glib::Bytes) {
46 unsafe {
47 ffi::g_memory_input_stream_add_bytes(
48 self.as_ref().to_glib_none().0,
49 bytes.to_glib_none().0,
50 );
51 }
52 }
53}
54
55impl<O: IsA<MemoryInputStream>> MemoryInputStreamExt for O {}