Trait rustbus::wire::marshal::traits::Signature[][src]

pub trait Signature {
    fn signature() -> Type;
fn alignment() -> usize; unsafe fn valid_slice(_bo: ByteOrder) -> bool { ... }
fn sig_str(s_buf: &mut SignatureBuffer) { ... } }

Required methods

fn signature() -> Type[src]

fn alignment() -> usize[src]

Loading content...

Provided methods

unsafe fn valid_slice(_bo: ByteOrder) -> bool[src]

If this returns true, it indicates that for implementing type T, Rust’s [T] is identical to DBus’s array format and can be copied into a message after aligning the first element.

The default implementation is false but can be overridden for a performance gain if it is valid.

Safety

Calls to this function should always be safe. Implementors should respect this property. The reason this method is unsafe is to indicate to people implementing Signature that overriding it has the potential to induce unsound behavior if the following rules aren’t followed:

  1. The type T implementing Signature must be Copy.
  2. The size of T must be equivalent to it’s DBus alignment (see here).
  3. Every possible bit-pattern must represent a valid instance of T. For example std::num::NonZeroU32 does not meet this requirement 0 is invalid.
  4. The type should not contain an Fd receieved from the message. When implementing Unmarshal the type should only dependent the 'buf lifetime. It should never require the use of 'fds.

Notes

  • This method exists because of limitiation with Rust type system. Should #[feature(specialization)] ever become stablized this will hopefully be unnecessary.
  • This method should use the ByteOrder to check if it matches native order before returning true. ByteOrder::NATIVE can be used to detect the native order.

fn sig_str(s_buf: &mut SignatureBuffer)[src]

Appends the signature of the type to the SignatureBuffer.

By using SignatureBuffer, implementations of this method can avoid unnecessary allocations by only allocating if a signature is dynamic.

The default implementation of sig_str can be pretty slow. If type, that Signature is being implemented for, has a static (unchanging) signature then overriding this method can have a significant performance benefit when marshal/unmarshalling the type inside variants.

Loading content...

Implementations on Foreign Types

impl<S: Signature> Signature for &S[src]

impl<E: Signature> Signature for (E,)[src]

impl<E1: Signature, E2: Signature> Signature for (E1, E2)[src]

impl<E1: Signature, E2: Signature, E3: Signature> Signature for (E1, E2, E3)[src]

impl<E1: Signature, E2: Signature, E3: Signature, E4: Signature> Signature for (E1, E2, E3, E4)[src]

impl<E1: Signature, E2: Signature, E3: Signature, E4: Signature, E5: Signature> Signature for (E1, E2, E3, E4, E5)[src]

impl<E: Signature> Signature for [E][src]

impl<E: Signature> Signature for &[E][src]

impl<K: Signature, V: Signature> Signature for HashMap<K, V>[src]

impl Signature for u64[src]

impl Signature for i64[src]

impl Signature for u32[src]

impl Signature for i32[src]

impl Signature for u16[src]

impl Signature for i16[src]

impl Signature for u8[src]

impl Signature for bool[src]

impl Signature for String[src]

impl Signature for &str[src]

impl Signature for &dyn AsRawFd[src]

impl<E: Signature> Signature for Vec<E>[src]

impl<E: Signature + Clone> Signature for Cow<'_, [E]>[src]

Loading content...

Implementors

impl Signature for UnixFd[src]

impl Signature for Variant<'_, '_>[src]

impl Signature for SignatureWrapper<'_>[src]

impl<'a, E: Copy + Marshal> Signature for OptimizedMarshal<'a, E>[src]

impl<S: AsRef<str>> Signature for ObjectPath<S>[src]

Loading content...