Struct zvariant::Signature[][src]

pub struct Signature<'a> { /* fields omitted */ }
Expand description

String that identifies the type of an encoded value.

Examples

use core::convert::TryFrom;
use zvariant::Signature;

// Valid signatures
let s = Signature::try_from("").unwrap();
assert_eq!(s, "");
let s = Signature::try_from("y").unwrap();
assert_eq!(s, "y");
let s = Signature::try_from("xs").unwrap();
assert_eq!(s, "xs");
let s = Signature::try_from("(ysa{sd})").unwrap();
assert_eq!(s, "(ysa{sd})");
let s = Signature::try_from("a{sd}").unwrap();
assert_eq!(s, "a{sd}");

// Invalid signatures
Signature::try_from("z").unwrap_err();
Signature::try_from("(xs").unwrap_err();
Signature::try_from("xs)").unwrap_err();
Signature::try_from("s/").unwrap_err();
Signature::try_from("a").unwrap_err();
Signature::try_from("a{yz}").unwrap_err();

This is implemented so that multiple instances can share the same underlying signature string. Use slice method to create new signature that represents a portion of a signature

Implementations

The signature as a string.

The signature bytes.

Create a new Signature from given bytes.

Since the passed bytes are not checked for correctness, it’s provided for ease of Type implementations.

Same as from_bytes_unchecked, except it takes a static reference.

Same as from_bytes_unchecked, except it takes a string reference.

Same as from_str_unchecked, except it takes a static string reference.

Same as from_str_unchecked, except it takes an owned String.

the signature’s length.

if the signature is empty.

Creates an owned clone of self.

Creates an owned clone of self.

Returns a slice of self for the provided range.

Panics

Requires that begin <= end and end <= self.len(), otherwise slicing will panic.

Trait Implementations

The type signature, as a character.

The type signature, as a string.

👎 Deprecated since 2.0.2:

Please use the alignment function instead

The required padding alignment.

The required padding alignment for the given format.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

The resulting type after dereferencing.

Dereferences the value.

Deserialize this value from the given Serde deserializer. Read more

Formats the value using the given formatter. Read more

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Serialize this value into the given Serde serializer. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Try to create a Signature from a string.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Get the signature for the implementing type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.