pub struct Message {
pub id: Uuid,
pub from_palace: String,
pub to_palace: String,
pub purpose: String,
pub sent_at: DateTime<Utc>,
pub read: bool,
pub content: String,
}Expand description
Decoded view of a message drawer.
Why: inbox-check and the HTTP GET /api/v1/messages endpoint both want
a typed view of every message field, not the raw Vec<String> of tags.
What: Owned strings plus the drawer id and content, populated by
Message::from_drawer.
Test: decode_message_from_drawer_round_trips.
Fields§
§id: Uuid§from_palace: String§to_palace: String§purpose: String§sent_at: DateTime<Utc>§read: bool§content: StringImplementations§
Source§impl Message
impl Message
Sourcepub fn from_drawer(drawer: &Drawer) -> Option<Self>
pub fn from_drawer(drawer: &Drawer) -> Option<Self>
Decode a drawer that carries the message tag namespace.
Why: drawers are stored verbatim and the message envelope lives in
tags; centralising the parse keeps the inbox handler clean and
surfaces any malformed-tag failures with a uniform error.
What: returns Some(Message) when the drawer carries the
MSG_MARKER_TAG and every required field is present and parseable;
returns None (with a debug log) on any missing-field or parse error
so a single corrupt drawer can’t poison the whole inbox. Unknown
read values default to false — better to re-deliver a message
than to silently swallow it.
Test: decode_message_from_drawer_round_trips,
decode_skips_non_message_drawer.
Sourcepub fn to_injection_block(&self) -> String
pub fn to_injection_block(&self) -> String
Format the message as the Markdown block the SessionStart hook injects via stdout.
Why: Claude Code’s SessionStart hook ingests stdout verbatim, so the
receiver needs a self-contained, model-readable block per message
(who, why, when, and the body) rather than raw JSON.
What: returns a multi-line ## Message from <from> heading plus a
purpose/sent-at metadata line and the body. The caller concatenates
multiple messages with a blank line between them; the receiver agent
then reads them in order.
Test: formatted_message_includes_from_purpose_and_body.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Message
impl<'de> Deserialize<'de> for Message
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>,
Auto Trait Implementations§
impl Freeze for Message
impl RefUnwindSafe for Message
impl Send for Message
impl Sync for Message
impl Unpin for Message
impl UnsafeUnpin for Message
impl UnwindSafe for Message
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<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more