pub struct MessageSegment {
pub messages: Vec<Message>,
pub tool_call_ids: HashSet<String>,
pub is_tool_chain: bool,
pub token_estimate: u32,
}Expand description
A segment of conversation that should be treated as atomic during truncation.
Ensures tool-call relationships are preserved: an assistant’s tool_call and the corresponding tool results form a single segment.
Fields§
§messages: Vec<Message>Messages in this segment
tool_call_ids: HashSet<String>Unique tool call IDs referenced in this segment
is_tool_chain: boolWhether this segment contains a tool call chain (assistant call + results)
token_estimate: u32Approximate token count (for sorting/filtering)
Implementations§
Source§impl MessageSegment
impl MessageSegment
Sourcepub fn from_message(message: Message) -> Self
pub fn from_message(message: Message) -> Self
Create a new segment containing a single message.
Sourcepub fn merge(&mut self, other: MessageSegment)
pub fn merge(&mut self, other: MessageSegment)
Merge another segment into this one.
Sourcepub fn contains_tool_result(&self, tool_call_id: &str) -> bool
pub fn contains_tool_result(&self, tool_call_id: &str) -> bool
Check if this segment contains a tool result for the given tool call ID.
Sourcepub fn contains_tool_call(&self, tool_call_id: &str) -> bool
pub fn contains_tool_call(&self, tool_call_id: &str) -> bool
Check if this segment contains the tool call (assistant message) for the given ID.
Sourcepub fn get_missing_results(&self) -> Vec<&str>
pub fn get_missing_results(&self) -> Vec<&str>
Get the IDs of tool calls that are missing their results in this segment.
Trait Implementations§
Source§impl Clone for MessageSegment
impl Clone for MessageSegment
Source§fn clone(&self) -> MessageSegment
fn clone(&self) -> MessageSegment
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for MessageSegment
impl RefUnwindSafe for MessageSegment
impl Send for MessageSegment
impl Sync for MessageSegment
impl Unpin for MessageSegment
impl UnsafeUnpin for MessageSegment
impl UnwindSafe for MessageSegment
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
Mutably borrows from an owned value. Read more