Trait StringLike

Source
pub trait StringLike: ToOwned {
    const NAME: &'static str;

    // Required methods
    fn new_unchecked(_: &str) -> &Self;
    fn new_unchecked_owned(_: String) -> <Self as ToOwned>::Owned;
    fn is_valid(_: &str) -> Result<(), InvalidStringError>;

    // Provided methods
    fn new(s: &str) -> Result<&Self, InvalidStringError> { ... }
    fn new_owned<S: Into<String>>(
        s: S,
    ) -> Result<<Self as ToOwned>::Owned, InvalidStringError> { ... }
}
Expand description

A D-Bus string-like type - a basic (non-container) type with variable length.

It wraps a str, which means that it is unsized.

Required Associated Constants§

Source

const NAME: &'static str

The name of the type

Required Methods§

Source

fn new_unchecked(_: &str) -> &Self

Creates a new borrowed string without actually checking that it is valid.

Sending this over D-Bus if actually invalid, could result in e g immediate disconnection from the server.

Source

fn new_unchecked_owned(_: String) -> <Self as ToOwned>::Owned

Creates a new owned string without actually checking that it is valid.

Sending this over D-Bus if actually invalid, could result in e g immediate disconnection from the server.

Source

fn is_valid(_: &str) -> Result<(), InvalidStringError>

Checks whether or not a string is valid.

Provided Methods§

Source

fn new(s: &str) -> Result<&Self, InvalidStringError>

Creates a new borrowed string

Source

fn new_owned<S: Into<String>>( s: S, ) -> Result<<Self as ToOwned>::Owned, InvalidStringError>

Creates a new owned string

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl StringLike for BusName

Source§

const NAME: &'static str = "BusName"

Source§

impl StringLike for DBusStr

Source§

const NAME: &'static str = "DBusStr"

Source§

impl StringLike for ErrorName

Source§

const NAME: &'static str = "ErrorName"

Source§

impl StringLike for InterfaceName

Source§

const NAME: &'static str = "InterfaceName"

Source§

impl StringLike for MemberName

Source§

const NAME: &'static str = "MemberName"

Source§

impl StringLike for ObjectPath

Source§

const NAME: &'static str = "ObjectPath"

Source§

impl StringLike for SignatureMulti

Source§

const NAME: &'static str = "SignatureMulti"

Source§

impl StringLike for SignatureSingle

Source§

const NAME: &'static str = "SignatureSingle"