pub struct ServiceIdentity { /* private fields */ }Expand description
A service installation, independent of its binary version or process ID.
Generate a UUID once per service and store its bytes in the consumer package.
Never generate a new UUID at startup or per release. Also use a reverse-DNS name, for example ninja.kunobi.kache.
Profiles separate installations such as stable and dev; instances allow
multiple services within one profile. Each component is canonical lowercase
ASCII to avoid aliases on case-insensitive filesystems.
Implementations§
Source§impl ServiceIdentity
impl ServiceIdentity
Sourcepub fn new(
id: [u8; 16],
application: impl Into<String>,
profile: impl Into<String>,
instance: impl Into<String>,
) -> Result<Self>
pub fn new( id: [u8; 16], application: impl Into<String>, profile: impl Into<String>, instance: impl Into<String>, ) -> Result<Self>
Validate an identity without creating directories or changing permissions.
Sourcepub fn id(&self) -> &[u8; 16]
pub fn id(&self) -> &[u8; 16]
Package-owned UUID bytes, fixed across all versions of this service.
Sourcepub fn application(&self) -> &str
pub fn application(&self) -> &str
Application-owned name. It must remain stable across binary upgrades.
Sourcepub fn paths(&self, user_root: impl AsRef<Path>) -> Result<ServicePaths>
pub fn paths(&self, user_root: impl AsRef<Path>) -> Result<ServicePaths>
Derive disjoint paths below a private per-user runtime directory.
The caller secures the root and creates these directories. Prefixes avoid Windows device names; distinct components cannot alias through separators. No version is included, so an upgrader finds its predecessor’s resources.
Fails when the directory leaves no room for ServicePaths::control_socket
in a Unix socket address; the error says how long it may be. Check the
application’s own sockets with ServicePaths::sockets.