Struct Signature

Source
pub struct Signature(/* private fields */);
Expand description

A D-Bus signature.

§Examples

use tokio_dbus::Signature;

const SIG: &Signature = Signature::new_const(b"aaaai");

assert!(Signature::new(b"aai").is_ok());

Implementations§

Source§

impl Signature

Source

pub const EMPTY: &'static Signature

The empty signature.

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

let body = BodyBuf::new();
assert_eq!(body.signature(), Signature::EMPTY);
Source

pub const SIGNATURE: &'static Signature

The signature of a Signature.

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

let mut body = BodyBuf::new();
body.store(Signature::new(b"g")?);

assert_eq!(body.signature(), Signature::SIGNATURE);
Source

pub const OBJECT_PATH: &'static Signature

The signature of an object path.

§Examples
use tokio_dbus::{BodyBuf, Signature, ObjectPath};

let mut body = BodyBuf::new();
body.store(ObjectPath::new(b"/org/freedesktop/DBus")?);

assert_eq!(body.signature(), Signature::OBJECT_PATH);
Source

pub const STRING: &'static Signature

The signature of a nul-terminated string.

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

let mut body = BodyBuf::new();
body.store("Hello World!");

assert_eq!(body.signature(), Signature::STRING);
Source

pub const VARIANT: &'static Signature

The signature of a variant value.

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

let mut body = BodyBuf::new();
body.store(Variant::U32(10u32));

assert_eq!(body.signature(), Signature::VARIANT);
Source

pub const BYTE: &'static Signature

A single byte.

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

let mut body = BodyBuf::new();

body.store(10u8);

assert_eq!(body.signature(), Signature::BYTE);
Source

pub const INT16: &'static Signature

Signed (two’s complement) 16-bit integer.

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

let mut body = BodyBuf::new();

body.store(10i16);

assert_eq!(body.signature(), Signature::INT16);
Source

pub const UINT16: &'static Signature

Unsigned 16-bit integer.

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

let mut body = BodyBuf::new();

body.store(10u16);

assert_eq!(body.signature(), Signature::UINT16);
Source

pub const INT32: &'static Signature

Signed (two’s complement) 32-bit integer

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

let mut body = BodyBuf::new();

body.store(10i32);

assert_eq!(body.signature(), Signature::INT32);
Source

pub const UINT32: &'static Signature

Unsigned 32-bit integer

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

let mut body = BodyBuf::new();

body.store(10u32);

assert_eq!(body.signature(), Signature::UINT32);
Source

pub const INT64: &'static Signature

Signed (two’s complement) 64-bit integer (mnemonic: x and t are the first characters in “sixty” not already used for something more common)

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

let mut body = BodyBuf::new();

body.store(10i64);

assert_eq!(body.signature(), Signature::INT64);
Source

pub const UINT64: &'static Signature

Unsigned 64-bit integer

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

let mut body = BodyBuf::new();

body.store(10u64);

assert_eq!(body.signature(), Signature::UINT64);
Source

pub const DOUBLE: &'static Signature

IEEE 754 double-precision floating point

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

let mut body = BodyBuf::new();

body.store(3.1415f64);

assert_eq!(body.signature(), Signature::DOUBLE);
Source

pub const UNIX_FD: &'static Signature

Unsigned 32-bit integer representing an index into an out-of-band array of file descriptors, transferred via some platform-specific mechanism (mnemonic: h for handle)

Source

pub const fn new_const(signature: &[u8]) -> &Signature

Construct a new signature with validation inside of a constant context.

This will panic in case the signature is invalid.

use tokio_dbus::Signature;

const BAD: &Signature = Signature::new_const(b"(a)");
§Examples
use tokio_dbus::Signature;

const SIG: &Signature = Signature::new_const(b"i(ai)");
Source

pub fn new<S>(signature: &S) -> Result<&Signature, SignatureError>
where S: AsRef<[u8]> + ?Sized,

Try to construct a new signature with validation.

Source

pub const unsafe fn new_unchecked(signature: &[u8]) -> &Signature

Construct a new signature without validation. The caller is responsible for ensuring that the signature is valid.

§Safety

The caller must ensure that the signature is a valid signature.

Source

pub const fn empty() -> &'static Signature

Construct a new empty signature.

Source

pub fn is_empty(&self) -> bool

Test if the signature is empty.

Source

pub fn len(&self) -> usize

Get the length of the signature in bytes.

Source

pub fn iter(&self) -> Iter<'_>

Source

pub fn as_str(&self) -> &str

Get the signature as a string.

Source

pub fn as_bytes(&self) -> &[u8]

Get the signature as a byte slice.

Trait Implementations§

Source§

impl AsRef<Signature> for Signature

Source§

fn as_ref(&self) -> &Signature

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<Signature> for SignatureBuf

Source§

fn as_ref(&self) -> &Signature

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Borrow<Signature> for SignatureBuf

Source§

fn borrow(&self) -> &Signature

Immutably borrows from an owned value. Read more
Source§

impl Debug for Signature

Source§

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

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

impl Hash for Signature

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
Source§

impl PartialEq<&Signature> for SignatureBuf

Equality check between a borrowed Signature and SignatureBuf.

§Examples

use tokio_dbus::{Signature, SignatureBuf};

assert_eq!(SignatureBuf::empty(), *Signature::EMPTY);
assert_eq!(SignatureBuf::new(b"s")?, *Signature::STRING);
Source§

fn eq(&self, other: &&Signature) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<&str> for Signature

Equality check between str and a Signature.

§Examples

use tokio_dbus::{Signature, SignatureBuf};

assert_eq!(*Signature::EMPTY, *"");
assert_eq!(*Signature::STRING, *"s");
Source§

fn eq(&self, other: &&str) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<[u8]> for &Signature

Equality check between [[u8]] and a borrowed Signature.

§Examples

use tokio_dbus::{Signature, SignatureBuf};

assert_eq!(Signature::EMPTY, b""[..]);
assert_eq!(Signature::STRING, b"s"[..]);
Source§

fn eq(&self, other: &[u8]) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<[u8]> for Signature

Equality check between [[u8]] and a Signature.

§Examples

use tokio_dbus::{Signature, SignatureBuf};

assert_eq!(*Signature::EMPTY, b""[..]);
assert_eq!(*Signature::STRING, b"s"[..]);
Source§

fn eq(&self, other: &[u8]) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<const N: usize> PartialEq<[u8; N]> for &Signature

Equality check between [[u8; N]] and a borrowed Signature.

§Examples

use tokio_dbus::{Signature, SignatureBuf};

assert_eq!(Signature::EMPTY, b"");
assert_eq!(Signature::STRING, b"s");
Source§

fn eq(&self, other: &[u8; N]) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<const N: usize> PartialEq<[u8; N]> for Signature

Equality check between [[u8; N]] and a Signature.

§Examples

use tokio_dbus::{Signature, SignatureBuf};

assert_eq!(Signature::EMPTY, b"");
assert_eq!(Signature::STRING, b"s");
Source§

fn eq(&self, other: &[u8; N]) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Signature> for SignatureBuf

Equality check between Signature and SignatureBuf.

§Examples

use tokio_dbus::{Signature, SignatureBuf};

assert_eq!(SignatureBuf::empty(), *Signature::EMPTY);
assert_eq!(SignatureBuf::new(b"s")?, *Signature::STRING);
Source§

fn eq(&self, other: &Signature) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<SignatureBuf> for &Signature

Equality check between SignatureBuf and a borrowed Signature.

§Examples

use tokio_dbus::{Signature, SignatureBuf};

assert_eq!(Signature::EMPTY, SignatureBuf::empty());
assert_eq!(Signature::STRING, SignatureBuf::new(b"s")?);
Source§

fn eq(&self, other: &SignatureBuf) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<SignatureBuf> for Signature

Equality check between SignatureBuf and Signature.

§Examples

use tokio_dbus::{Signature, SignatureBuf};

assert_eq!(*Signature::EMPTY, SignatureBuf::empty());
assert_eq!(*Signature::STRING, SignatureBuf::new(b"s")?);
Source§

fn eq(&self, other: &SignatureBuf) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<str> for &Signature

Equality check between str and a borrowed Signature.

§Examples

use tokio_dbus::{Signature, SignatureBuf};

assert_eq!(Signature::EMPTY, *"");
assert_eq!(Signature::STRING, *"s");
Source§

fn eq(&self, other: &str) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<str> for Signature

Equality check between str and a Signature.

§Examples

use tokio_dbus::{Signature, SignatureBuf};

assert_eq!(*Signature::EMPTY, *"");
assert_eq!(*Signature::STRING, *"s");
Source§

fn eq(&self, other: &str) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq for Signature

Source§

fn eq(&self, other: &Signature) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl ToOwned for Signature

Source§

type Owned = SignatureBuf

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> <Signature as ToOwned>::Owned

Creates owned data from borrowed data, usually by cloning. Read more
1.63.0 · Source§

fn clone_into(&self, target: &mut Self::Owned)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl Arguments for Signature

Source§

impl Eq for Signature

Source§

impl Read for Signature

Source§

impl Storable for &Signature

Storable implementation for &Signature.

§Examples

use tokio_dbus::BodyBuf;
use tokio_dbus::Signature;

let mut body = BodyBuf::new();

body.store(10u16)?;
body.store(Signature::new("us")?)?;

assert_eq!(body.signature(), "qg");
Source§

impl StructuralPartialEq for Signature

Source§

impl Write for Signature

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