pub struct Character {
pub nickname: String,
pub emoji: String,
pub palette: Palette,
}Expand description
A character for an identity: human-readable nickname, emoji, and palette.
Constructed deterministically from a seed (typically the DID). The same seed always produces the same Character — operators can rely on “🦊 foxtrot-meadow” persisting across daemon restarts, machine migration, and process boundaries.
Fields§
§nickname: StringAdjective-noun pair, lowercase, hyphen-joined. e.g. "foxtrot-meadow".
emoji: StringSingle-codepoint (or VS-16-qualified) emoji glyph. e.g. "🦊".
palette: PaletteTwo-color palette for terminal/UI display.
Implementations§
Source§impl Character
impl Character
Sourcepub fn from_did(did: &str) -> Self
pub fn from_did(did: &str) -> Self
Derive a Character from a wire DID (e.g. did:wire:paul-a1b2c3d4).
SHA-256 of the DID drives both nickname/emoji selection and HSL hue. The function is total and deterministic — every input string yields some valid Character.
Sourcepub fn from_card(card: &Value) -> Self
pub fn from_card(card: &Value) -> Self
Derive a Character from a pinned peer’s agent-card JSON object.
v0.7.0-alpha.6: when a peer has published their operator-chosen
character (display.nickname / display.emoji on their signed
agent-card), we honor it. Otherwise falls back to auto-derived
from their DID — same as from_did.
v0.7.0-alpha.8 (review-fix #1): peer-published override fields
are sanitized (control chars stripped, length-capped) before use
so a malicious peer cannot inject ANSI/OSC escape sequences via
their display.nickname / display.emoji and execute terminal
control codes on every wire peers / wire whoami render.
Override that fully sanitizes to empty falls back to auto-derived.
v0.7.0-alpha.8 (review-fix #8): missing or non-string did
returns a distinctive “unknown peer” sentinel character rather
than collapsing all such peers onto the empty-string-derived
character. Surfaces partially-corrupt pinned cards to operators
rather than masking them as one fake identity.
Backward compat: agent-cards without the display field land in
the auto-derived path automatically.
Sourcepub fn from_did_with_override(
did: &str,
nickname_override: Option<&str>,
emoji_override: Option<&str>,
) -> Self
pub fn from_did_with_override( did: &str, nickname_override: Option<&str>, emoji_override: Option<&str>, ) -> Self
Derive a Character from a DID, optionally overriding the nickname and/or emoji with operator-chosen values.
v0.7.0-alpha.3: agents can name themselves. The palette stays deterministic (derived from DID hash) so the visual color identity remains stable even when the operator picks a custom name; only the textual + emoji fields override. Empty-string override is treated as “unset” (falls back to auto-derived).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Character
impl<'de> Deserialize<'de> for Character
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Character
impl StructuralPartialEq for Character
Auto Trait Implementations§
impl Freeze for Character
impl RefUnwindSafe for Character
impl Send for Character
impl Sync for Character
impl Unpin for Character
impl UnsafeUnpin for Character
impl UnwindSafe for Character
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.