Skip to content
This repository was archived by the owner on Jun 8, 2021. It is now read-only.

Commit 3b60b4d

Browse files
committed
Bind Variant::new_from_bytes
1 parent 535ed31 commit 3b60b4d

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/variant.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ use StaticType;
5353
use Type;
5454
use Value;
5555
use VariantTy;
56+
use bytes::Bytes;
5657

5758
glib_wrapper! {
5859
/// A generic immutable value capable of carrying various types.
@@ -141,6 +142,19 @@ impl Variant {
141142
}
142143
}
143144
}
145+
146+
/// Constructs a new serialised-mode GVariant instance.
147+
pub fn new_from_bytes<T: StaticVariantType>(bytes: &Bytes, trusted: bool) -> Self {
148+
unsafe {
149+
from_glib_none(glib_sys::g_variant_new_from_bytes(
150+
T::static_variant_type().as_ptr() as *const _,
151+
bytes.to_glib_none().0,
152+
trusted.to_glib(),
153+
)
154+
)
155+
}
156+
}
157+
144158
}
145159

146160
unsafe impl Send for Variant {}

0 commit comments

Comments
 (0)