pub struct ConversationBlock {
pub role: Role,
pub content: Vec<u8>,
pub tool_call_id: Option<String>,
}Expand description
CONVERSATION block — represents a single chat turn.
Each turn in a conversation (system prompt, user message, assistant
response, tool output) becomes one CONVERSATION block. The role
field determines the speaker, and content holds the message body.
Field layout within body:
┌──────────┬───────────┬──────────────┬──────────────────────────┐
│ Field ID │ Wire Type │ Name │ Description │
├──────────┼───────────┼──────────────┼──────────────────────────┤
│ 1 │ Varint │ role │ Role enum byte │
│ 2 │ Bytes │ content │ Message body (UTF-8) │
│ 3 │ Bytes │ tool_call_id │ Tool call ID (optional) │
└──────────┴───────────┴──────────────┴──────────────────────────┘Field 3 is only present when role is Tool, linking the response
back to the tool invocation that produced it.
Fields§
§role: Role§content: Vec<u8>§tool_call_id: Option<String>Optional tool call ID, present only for Role::Tool turns.
Implementations§
Source§impl ConversationBlock
impl ConversationBlock
Sourcepub fn encode_body(&self) -> Vec<u8> ⓘ
pub fn encode_body(&self) -> Vec<u8> ⓘ
Serialize this block’s fields into a TLV-encoded body.
Sourcepub fn decode_body(buf: &[u8]) -> Result<Self, TypeError>
pub fn decode_body(buf: &[u8]) -> Result<Self, TypeError>
Deserialize a CONVERSATION block from a TLV-encoded body.
Trait Implementations§
Source§impl Clone for ConversationBlock
impl Clone for ConversationBlock
Source§fn clone(&self) -> ConversationBlock
fn clone(&self) -> ConversationBlock
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 moreSource§impl Debug for ConversationBlock
impl Debug for ConversationBlock
Source§impl PartialEq for ConversationBlock
impl PartialEq for ConversationBlock
impl Eq for ConversationBlock
impl StructuralPartialEq for ConversationBlock
Auto Trait Implementations§
impl Freeze for ConversationBlock
impl RefUnwindSafe for ConversationBlock
impl Send for ConversationBlock
impl Sync for ConversationBlock
impl Unpin for ConversationBlock
impl UnsafeUnpin for ConversationBlock
impl UnwindSafe for ConversationBlock
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