pub trait InstanceIdentity {
// Required methods
fn kind() -> &'static str;
fn write_identity(&self, f: &mut Formatter<'_>) -> Result;
}Expand description
An instance of a facility that wants to save persistent state (caller-provided impl)
Each value of a type implementing InstanceIdentity
designates a specific instance of a specific facility.
For example, HsNickname implements state_dir::InstanceIdentity.
The kind and identity are slugs.
Required Methods§
Sourcefn kind() -> &'static str
fn kind() -> &'static str
Return the kind. For example hss for a Tor Hidden Service.
This must return a fixed string, since usually all instances represented the same Rust type are also the same kind.
The returned value must be valid as a slug.
Sourcefn write_identity(&self, f: &mut Formatter<'_>) -> Result
fn write_identity(&self, f: &mut Formatter<'_>) -> Result
Obtain identity
The instance identity distinguishes different instances of the same kind.
For example, for a Tor Hidden Service the identity is the nickname.
The generated string must be valid as a slug.
If it is not, the functions in this module will throw Bug errors.
(Returning fmt::Error will cause a panic, as is usual with the fmt API.)
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl InstanceIdentity for HsNickname
state-dir only.