pub struct HistoryMessage {
pub role: String,
pub content: String,
}Expand description
Simple {role, content} serializable form used over IPC.
Why: ChatCompletionRequestMessage is an async-openai enum with complex
shape that doesn’t round-trip cleanly through NDJSON IPC. A tiny
HistoryMessage is trivially serde-friendly and enough to rebuild the
typed messages on the sub-agent side.
What: Pair of role (“user”|“assistant”|“system”) and content strings.
Note: The into_typed() method (which converts back to
ChatCompletionRequestMessage) requires async-openai and therefore
lives in trusty-agents::session as a standalone helper function rather
than here. Call sites in trusty-agents use
trusty_agents::session::history_message_into_typed(msg).
Test: See trusty-agents::session tests + IPC round-trip in
trusty-agents::ipc::tests.
Fields§
§role: String§content: StringImplementations§
Source§impl HistoryMessage
impl HistoryMessage
Sourcepub fn user(content: impl Into<String>) -> HistoryMessage
pub fn user(content: impl Into<String>) -> HistoryMessage
Construct a HistoryMessage with role="user".
Why: Callers serialize a dialog turn over IPC without touching the
role string directly, avoiding typos.
What: Plain struct literal with role="user".
Test: Indirectly via history_message_typed_round_trip in
trusty-agents::session::tests.
Sourcepub fn assistant(content: impl Into<String>) -> HistoryMessage
pub fn assistant(content: impl Into<String>) -> HistoryMessage
Construct a HistoryMessage with role="assistant".
Why: Symmetric with user — keeps IPC construction declarative.
What: Plain struct literal with role="assistant".
Test: Indirectly via history_message_typed_round_trip in
trusty-agents::session::tests.
Trait Implementations§
Source§impl Clone for HistoryMessage
impl Clone for HistoryMessage
Source§fn clone(&self) -> HistoryMessage
fn clone(&self) -> HistoryMessage
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for HistoryMessage
impl Debug for HistoryMessage
Source§impl<'de> Deserialize<'de> for HistoryMessage
impl<'de> Deserialize<'de> for HistoryMessage
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<HistoryMessage, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<HistoryMessage, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
impl Eq for HistoryMessage
Source§impl PartialEq for HistoryMessage
impl PartialEq for HistoryMessage
Source§impl Serialize for HistoryMessage
impl Serialize for HistoryMessage
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for HistoryMessage
Auto Trait Implementations§
impl Freeze for HistoryMessage
impl RefUnwindSafe for HistoryMessage
impl Send for HistoryMessage
impl Sync for HistoryMessage
impl Unpin for HistoryMessage
impl UnsafeUnpin for HistoryMessage
impl UnwindSafe for HistoryMessage
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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.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