Skip to main content

StoreArray

Struct StoreArray 

Source
pub struct StoreArray<'a, T>
where T: Aligned,
{ /* private fields */ }
Expand description

Write a typed array.

See BodyBuf::store_array.

Implementations§

Source§

impl<'a, T> StoreArray<'a, T>
where T: Aligned,

Source

pub fn finish(self)

Finish writing the array.

This will also be done implicitly once this is dropped.

See BodyBuf::store_array.

Source§

impl<T> StoreArray<'_, T>
where T: Aligned,

Source

pub fn store(&mut self, value: T::Return<'_>)
where T: Marker, for<'b> T::Return<'b>: Storable,

Store a value and return the builder for the next value to store.

See BodyBuf::store_array.

Source

pub fn store_struct(&mut self) -> StoreStruct<'_, T>
where T: Fields,

Write a struct inside of the array.

See BodyBuf::store_array.

Source§

impl StoreArray<'_, Variant>

Source

pub fn store_variant(&mut self, signature: &Signature) -> StoreVariant<'_>

Write a variant inside of the array.

§Examples
use tokio_dbus::{ty, BodyBuf, Signature, Variant};

let mut buf = BodyBuf::new();

let mut array = buf.store_array::<ty::Variant>()?;
array.store_variant(Signature::STRING).store("Hello World!");
array.store_variant(Signature::UINT32).store(42u32);
array.finish();

assert_eq!(buf.signature(), "av");

let mut buf = buf.as_body();
let mut array = buf.load_array::<ty::Variant>()?;
assert_eq!(array.load_variant()?, Some(Variant::String("Hello World!")));
assert_eq!(array.load_variant()?, Some(Variant::U32(42)));
assert_eq!(array.load_variant()?, None);
Source§

impl<K, V> StoreArray<'_, Dict<K, V>>
where K: Marker, V: Marker,

Source

pub fn store_entry(&mut self) -> StoreStruct<'_, (K, V)>

Write a dict entry inside of the array.

§Examples
use tokio_dbus::{ty, BodyBuf, Signature, Variant};

let mut buf = BodyBuf::new();

let mut dict = buf.store_array::<ty::Dict<ty::Str, ty::Variant>>()?;
dict.store_entry().store("Id").store(Variant::String("example")).finish();
dict.store_entry().store("ItemIsMenu").store(Variant::Bool(false)).finish();
dict.finish();

assert_eq!(buf.signature(), "a{sv}");

let mut buf = buf.as_body();
let mut dict = buf.load_array::<ty::Dict<ty::Str, ty::Variant>>()?;

assert_eq!(dict.load_entry()?, Some(("Id", Variant::String("example"))));
assert_eq!(dict.load_entry()?, Some(("ItemIsMenu", Variant::Bool(false))));
assert_eq!(dict.load_entry()?, None);
Source§

impl<T> StoreArray<'_, Array<T>>
where T: Aligned,

Source

pub fn store_array(&mut self) -> StoreArray<'_, T>

Write an array inside of the array.

See BodyBuf::store_array.

Source§

impl StoreArray<'_, u8>

Source

pub fn write_slice(&mut self, bytes: &[u8])

Extend a byte array with the given slice.

See BodyBuf::store_array.

Trait Implementations§

Source§

impl<T> Drop for StoreArray<'_, T>
where T: Aligned,

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<'a, T> !UnwindSafe for StoreArray<'a, T>

§

impl<'a, T> Freeze for StoreArray<'a, T>

§

impl<'a, T> RefUnwindSafe for StoreArray<'a, T>
where T: RefUnwindSafe,

§

impl<'a, T> Send for StoreArray<'a, T>
where T: Send,

§

impl<'a, T> Sync for StoreArray<'a, T>
where T: Sync,

§

impl<'a, T> Unpin for StoreArray<'a, T>
where T: Unpin,

§

impl<'a, T> UnsafeUnpin for StoreArray<'a, T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.