Skip to main content

Decode

Trait Decode 

Source
pub trait Decode: Sized {
    const ALIGNMENT: Alignment;

    // Required method
    fn decode(body: &mut Body<'_>) -> Result<Self>;
}
Expand description

A Rust value which can be read from a D-Bus message body.

§Examples

use tokio_dbus::{BodyBuf, Signature};
use tokio_dbus_runtime::Decode;

let mut buf = BodyBuf::new();
buf.extend_signature(Signature::new("su")?)?;
buf.raw().store("Hello");
buf.raw().store(42u32);

let mut body = buf.as_body();
assert_eq!(String::decode(&mut body)?, "Hello");
assert_eq!(u32::decode(&mut body)?, 42);

Required Associated Constants§

Source

const ALIGNMENT: Alignment

The alignment of the encoded value.

Required Methods§

Source

fn decode(body: &mut Body<'_>) -> Result<Self>

Read one value from the body.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Decode for ObjectPathBuf

Source§

const ALIGNMENT: Alignment = Alignment::U32

Source§

fn decode(body: &mut Body<'_>) -> Result<Self>

Source§

impl Decode for SignatureBuf

Source§

const ALIGNMENT: Alignment = Alignment::BYTE

Source§

fn decode(body: &mut Body<'_>) -> Result<Self>

Source§

impl Decode for String

Source§

const ALIGNMENT: Alignment = Alignment::U32

Source§

fn decode(body: &mut Body<'_>) -> Result<Self>

Source§

impl Decode for bool

Source§

const ALIGNMENT: Alignment = Alignment::U32

Source§

fn decode(body: &mut Body<'_>) -> Result<Self>

Source§

impl Decode for f64

Source§

const ALIGNMENT: Alignment = Alignment::U64

Source§

fn decode(body: &mut Body<'_>) -> Result<Self>

Source§

impl Decode for i16

Source§

const ALIGNMENT: Alignment = Alignment::U16

Source§

fn decode(body: &mut Body<'_>) -> Result<Self>

Source§

impl Decode for i32

Source§

const ALIGNMENT: Alignment = Alignment::U32

Source§

fn decode(body: &mut Body<'_>) -> Result<Self>

Source§

impl Decode for i64

Source§

const ALIGNMENT: Alignment = Alignment::U64

Source§

fn decode(body: &mut Body<'_>) -> Result<Self>

Source§

impl Decode for u8

Source§

const ALIGNMENT: Alignment = Alignment::BYTE

Source§

fn decode(body: &mut Body<'_>) -> Result<Self>

Source§

impl Decode for u16

Source§

const ALIGNMENT: Alignment = Alignment::U16

Source§

fn decode(body: &mut Body<'_>) -> Result<Self>

Source§

impl Decode for u32

Source§

const ALIGNMENT: Alignment = Alignment::U32

Source§

fn decode(body: &mut Body<'_>) -> Result<Self>

Source§

impl Decode for u64

Source§

const ALIGNMENT: Alignment = Alignment::U64

Source§

fn decode(body: &mut Body<'_>) -> Result<Self>

Source§

impl<A, B, C, D, E, F, G, H, I, J, K, L> Decode for (A, B, C, D, E, F, G, H, I, J, K, L)
where A: Decode, B: Decode, C: Decode, D: Decode, E: Decode, F: Decode, G: Decode, H: Decode, I: Decode, J: Decode, K: Decode, L: Decode,

Source§

const ALIGNMENT: Alignment = Alignment::U64

Source§

fn decode(body: &mut Body<'_>) -> Result<Self>

Source§

impl<A, B, C, D, E, F, G, H, I, J, K> Decode for (A, B, C, D, E, F, G, H, I, J, K)
where A: Decode, B: Decode, C: Decode, D: Decode, E: Decode, F: Decode, G: Decode, H: Decode, I: Decode, J: Decode, K: Decode,

Source§

const ALIGNMENT: Alignment = Alignment::U64

Source§

fn decode(body: &mut Body<'_>) -> Result<Self>

Source§

impl<A, B, C, D, E, F, G, H, I, J> Decode for (A, B, C, D, E, F, G, H, I, J)
where A: Decode, B: Decode, C: Decode, D: Decode, E: Decode, F: Decode, G: Decode, H: Decode, I: Decode, J: Decode,

Source§

const ALIGNMENT: Alignment = Alignment::U64

Source§

fn decode(body: &mut Body<'_>) -> Result<Self>

Source§

impl<A, B, C, D, E, F, G, H, I> Decode for (A, B, C, D, E, F, G, H, I)
where A: Decode, B: Decode, C: Decode, D: Decode, E: Decode, F: Decode, G: Decode, H: Decode, I: Decode,

Source§

const ALIGNMENT: Alignment = Alignment::U64

Source§

fn decode(body: &mut Body<'_>) -> Result<Self>

Source§

impl<A, B, C, D, E, F, G, H> Decode for (A, B, C, D, E, F, G, H)
where A: Decode, B: Decode, C: Decode, D: Decode, E: Decode, F: Decode, G: Decode, H: Decode,

Source§

const ALIGNMENT: Alignment = Alignment::U64

Source§

fn decode(body: &mut Body<'_>) -> Result<Self>

Source§

impl<A, B, C, D, E, F, G> Decode for (A, B, C, D, E, F, G)
where A: Decode, B: Decode, C: Decode, D: Decode, E: Decode, F: Decode, G: Decode,

Source§

const ALIGNMENT: Alignment = Alignment::U64

Source§

fn decode(body: &mut Body<'_>) -> Result<Self>

Source§

impl<A, B, C, D, E, F> Decode for (A, B, C, D, E, F)
where A: Decode, B: Decode, C: Decode, D: Decode, E: Decode, F: Decode,

Source§

const ALIGNMENT: Alignment = Alignment::U64

Source§

fn decode(body: &mut Body<'_>) -> Result<Self>

Source§

impl<A, B, C, D, E> Decode for (A, B, C, D, E)
where A: Decode, B: Decode, C: Decode, D: Decode, E: Decode,

Source§

const ALIGNMENT: Alignment = Alignment::U64

Source§

fn decode(body: &mut Body<'_>) -> Result<Self>

Source§

impl<A, B, C, D> Decode for (A, B, C, D)
where A: Decode, B: Decode, C: Decode, D: Decode,

Source§

const ALIGNMENT: Alignment = Alignment::U64

Source§

fn decode(body: &mut Body<'_>) -> Result<Self>

Source§

impl<A, B, C> Decode for (A, B, C)
where A: Decode, B: Decode, C: Decode,

Source§

const ALIGNMENT: Alignment = Alignment::U64

Source§

fn decode(body: &mut Body<'_>) -> Result<Self>

Source§

impl<A, B> Decode for (A, B)
where A: Decode, B: Decode,

Source§

const ALIGNMENT: Alignment = Alignment::U64

Source§

fn decode(body: &mut Body<'_>) -> Result<Self>

Source§

impl<A> Decode for (A,)
where A: Decode,

Source§

const ALIGNMENT: Alignment = Alignment::U64

Source§

fn decode(body: &mut Body<'_>) -> Result<Self>

Source§

impl<K, V, S> Decode for HashMap<K, V, S>
where K: Decode + Eq + Hash, V: Decode, S: Default + BuildHasher,

Source§

const ALIGNMENT: Alignment = Alignment::U32

Source§

fn decode(body: &mut Body<'_>) -> Result<Self>

Source§

impl<K, V> Decode for BTreeMap<K, V>
where K: Decode + Ord, V: Decode,

Source§

const ALIGNMENT: Alignment = Alignment::U32

Source§

fn decode(body: &mut Body<'_>) -> Result<Self>

Source§

impl<T> Decode for Vec<T>
where T: Decode,

Source§

const ALIGNMENT: Alignment = Alignment::U32

Source§

fn decode(body: &mut Body<'_>) -> Result<Self>

Implementors§

Source§

impl Decode for Value

Source§

const ALIGNMENT: Alignment = Alignment::BYTE