pub enum BlockContent {
Show 13 variants
Code(CodeBlock),
Conversation(ConversationBlock),
FileTree(FileTreeBlock),
ToolResult(ToolResultBlock),
Document(DocumentBlock),
StructuredData(StructuredDataBlock),
Diff(DiffBlock),
Annotation(AnnotationBlock),
EmbeddingRef(EmbeddingRefBlock),
Image(ImageBlock),
Extension(ExtensionBlock),
End,
Unknown {
type_id: u8,
body: Vec<u8>,
},
}Expand description
The typed content within a block.
Each variant wraps the corresponding block struct from this crate.
The Unknown variant preserves unrecognized block types as raw bytes,
enabling forward compatibility: a decoder built against an older spec
can still read (and re-encode) blocks from a newer encoder.
┌─────────────────┬────────────────────────┐
│ Variant │ Block Type Wire ID │
├─────────────────┼────────────────────────┤
│ Code │ 0x01 │
│ Conversation │ 0x02 │
│ FileTree │ 0x03 │
│ ToolResult │ 0x04 │
│ Document │ 0x05 │
│ StructuredData │ 0x06 │
│ Diff │ 0x07 │
│ Annotation │ 0x08 │
│ EmbeddingRef │ 0x09 │
│ Image │ 0x0A │
│ Extension │ 0xFE │
│ End │ 0xFF │
│ Unknown │ any other byte │
└─────────────────┴────────────────────────┘Variants§
Code(CodeBlock)
Conversation(ConversationBlock)
FileTree(FileTreeBlock)
ToolResult(ToolResultBlock)
Document(DocumentBlock)
StructuredData(StructuredDataBlock)
Diff(DiffBlock)
Annotation(AnnotationBlock)
EmbeddingRef(EmbeddingRefBlock)
Image(ImageBlock)
Extension(ExtensionBlock)
End
Unknown
Raw body bytes for an unrecognized block type.
Implementations§
Source§impl BlockContent
impl BlockContent
Sourcepub fn encode_body(&self) -> Vec<u8> ⓘ
pub fn encode_body(&self) -> Vec<u8> ⓘ
Encode the typed content into a raw body byte vector.
For End, returns an empty vec (END blocks have no body).
For Unknown, returns the preserved raw bytes as-is.
Trait Implementations§
Source§impl Clone for BlockContent
impl Clone for BlockContent
Source§fn clone(&self) -> BlockContent
fn clone(&self) -> BlockContent
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 BlockContent
impl Debug for BlockContent
Source§impl PartialEq for BlockContent
impl PartialEq for BlockContent
impl StructuralPartialEq for BlockContent
Auto Trait Implementations§
impl Freeze for BlockContent
impl RefUnwindSafe for BlockContent
impl Send for BlockContent
impl Sync for BlockContent
impl Unpin for BlockContent
impl UnsafeUnpin for BlockContent
impl UnwindSafe for BlockContent
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