pub struct StoreStruct<'a, T> { /* private fields */ }
Expand description
Write a struct.
Implementations§
Source§impl<'a, T> StoreStruct<'a, T>
impl<'a, T> StoreStruct<'a, T>
Sourcepub fn store(
self,
value: <T::First as Marker>::Return<'_>,
) -> StoreStruct<'a, T::Remaining>
pub fn store( self, value: <T::First as Marker>::Return<'_>, ) -> StoreStruct<'a, T::Remaining>
Store a value and return the builder for the next value to store.
§Examples
use tokio_dbus::{BodyBuf, Endianness};
use tokio_dbus::ty;
let mut buf = BodyBuf::with_endianness(Endianness::LITTLE);
buf.store_struct::<(u16, u32)>()?
.store(10u16)
.store(10u32)
.finish();
assert_eq!(buf.signature(), b"(qu)");
assert_eq!(buf.get(), &[10, 0, 0, 0, 10, 0, 0, 0]);
Examples using unsized types:
use tokio_dbus::{BodyBuf, Endianness};
use tokio_dbus::ty;
let mut buf = BodyBuf::with_endianness(Endianness::LITTLE);
buf.store_struct::<(ty::Str,)>()?
.store("Hello World")
.finish();
assert_eq!(buf.signature(), b"(s)");
assert_eq!(buf.get(), &[11, 0, 0, 0, 72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 0]);
Sourcepub fn fields(self, arguments: T)where
T: Arguments,
pub fn fields(self, arguments: T)where
T: Arguments,
Store a value and return the builder for the next value to store.
§Examples
use tokio_dbus::{BodyBuf, Endianness};
use tokio_dbus::ty;
let mut buf = BodyBuf::with_endianness(Endianness::LITTLE);
buf.store_struct::<(u8, u32)>()?.fields((42u8, 42u32));
assert_eq!(buf.signature(), b"(yu)");
assert_eq!(buf.get(), &[42, 0, 0, 0, 42, 0, 0, 0]);
Sourcepub fn store_array<W, U>(self, writer: W) -> StoreStruct<'a, T::Remaining>
pub fn store_array<W, U>(self, writer: W) -> StoreStruct<'a, T::Remaining>
Store a value and return the builder for the next value to store.
§Examples
use tokio_dbus::{BodyBuf, Endianness};
use tokio_dbus::ty;
let mut buf = BodyBuf::with_endianness(Endianness::LITTLE);
buf.store_struct::<(ty::Array<u32>,)>()?
.store_array(|w| {
w.store(1);
w.store(2);
w.store(3);
w.store(4);
})
.finish();
assert_eq!(buf.signature(), b"(au)");
assert_eq!(buf.get(), &[16, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 4, 0, 0, 0]);
Sourcepub fn store_struct<W>(self, writer: W) -> StoreStruct<'a, T::Remaining>
pub fn store_struct<W>(self, writer: W) -> StoreStruct<'a, T::Remaining>
Store a value and return the builder for the next value to store.
Auto Trait Implementations§
impl<'a, T> Freeze for StoreStruct<'a, T>
impl<'a, T> RefUnwindSafe for StoreStruct<'a, T>where
T: RefUnwindSafe,
impl<'a, T> Send for StoreStruct<'a, T>where
T: Send,
impl<'a, T> Sync for StoreStruct<'a, T>where
T: Sync,
impl<'a, T> Unpin for StoreStruct<'a, T>where
T: Unpin,
impl<'a, T> !UnwindSafe for StoreStruct<'a, T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more