pub struct UserId(/* private fields */);Expand description
A validated CoPilot user id, kept exactly as sent (case included).
The lane JID embeds the exact id (http:copilot:u:<id>); the session and
IPC key (Self::session_key) is derived so that ids differing only in
case cannot share a directory on a case-insensitive filesystem.
Implementations§
Source§impl UserId
impl UserId
Sourcepub fn parse(raw: &str) -> Result<Self, InvalidUserId>
pub fn parse(raw: &str) -> Result<Self, InvalidUserId>
Validate a user id string (no trimming, no stripping).
Sourcepub fn from_json(raw: Option<&Value>) -> Result<Option<Self>, InvalidUserId>
pub fn from_json(raw: Option<&Value>) -> Result<Option<Self>, InvalidUserId>
The user_id field of a request body: missing, null or "" mean
“no user” (the shared anonymous lane); a valid string or integer is
accepted; anything else is rejected.
Sourcepub fn session_key(&self) -> String
pub fn session_key(&self) -> String
Session/IPC key of this user’s lane:
copilot-u-<lowercased id, first 20 chars>-<first 32 hex of sha256(exact id)>,
e.g. copilot-u-bob-81b637d8fcd2c6da6359e6963113a117.
At most 63 characters of [a-z0-9_-], so always a valid group
folder. The 128-bit hash of the exact id keeps Bob and bob (and
ids sharing a 20-char prefix) apart even where the filesystem folds
case, and makes it infeasible to pick an id whose key collides with
another user’s (and so share their session, IPC namespace and lane).