Skip to main content

Arguments

Struct Arguments 

Source
pub struct Arguments { /* private fields */ }
Expand description

The body of a message being built.

The signature of the arguments is declared up front, since generated code knows it at build time, after which each argument is written in order.

§Examples

use tokio_dbus::Signature;
use tokio_dbus_runtime::Arguments;

let mut arguments = Arguments::new(Signature::new("su")?)?;
arguments.store("Hello World!");
arguments.store(&42u32);

Implementations§

Source§

impl Arguments

Source

pub fn new(signature: &Signature) -> Result<Self>

Construct an argument list matching the given signature.

Source

pub fn new_const(signature: &'static Signature) -> Self

Construct an argument list matching a signature which is known at compile time.

This is the infallible form of new(), for the common case where the signature comes out of Signature::new_const and has therefore already been validated at compile time.

§Examples
use tokio_dbus::Signature;
use tokio_dbus_runtime::Arguments;

const SIGNATURE: &Signature = Signature::new_const(b"su");

let mut arguments = Arguments::new_const(SIGNATURE);
arguments.store("Hello World!");
arguments.store(&42u32);
Source

pub fn empty() -> Self

Construct an empty argument list.

Source

pub fn store<T>(&mut self, value: T) -> &mut Self
where T: Encode,

Write the next argument.

Source

pub fn store_variant<T>(&mut self, signature: &Signature, value: T) -> &mut Self
where T: Encode,

Write the next argument as a variant containing a value of the given type.

The signature is the one of the value inside the variant, not the v of the variant itself.

§Examples
use tokio_dbus::Signature;
use tokio_dbus_runtime::Arguments;

let mut arguments = Arguments::new(Signature::VARIANT)?;
arguments.store_variant(Signature::UINT32, 42u32);
Source

pub fn store_variant_dict(&mut self) -> VariantDict<'_>

Write the next argument as an a{sv}, which is how a set of properties of differing types is carried.

§Examples
use tokio_dbus::Signature;
use tokio_dbus_runtime::Arguments;

let mut arguments = Arguments::new(Signature::new("a{sv}")?)?;

let mut dict = arguments.store_variant_dict();
dict.entry("Version", Signature::UINT32, 3u32);
dict.entry("Status", Signature::STRING, "normal");
dict.finish();

Trait Implementations§

Source§

impl Debug for Arguments

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Arguments

Source§

fn default() -> Arguments

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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.