Trait tor_persist::state_dir::InstanceIdentity

source ·
pub trait InstanceIdentity {
    // Required methods
    fn kind() -> &'static str;
    fn write_identity(&self, f: &mut Formatter<'_>) -> Result;
}
Available on crate feature state-dir only.
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§

source

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.

source

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.)

Object Safety§

This trait is not object safe.

Implementors§