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§
Required Methods§
Sourcefn new_unchecked(_: &str) -> &Self
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.
Sourcefn new_unchecked_owned(_: String) -> <Self as ToOwned>::Owned
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.
Provided Methods§
Sourcefn new(s: &str) -> Result<&Self, InvalidStringError>
fn new(s: &str) -> Result<&Self, InvalidStringError>
Creates a new borrowed 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.