pub struct CodeBlock {
pub lang: Lang,
pub path: String,
pub content: Vec<u8>,
pub line_range: Option<(u32, u32)>,
}Expand description
CODE block — represents a source code file or fragment.
This is the most common block type in practice: every source file, snippet, or code region in a context pack becomes a CODE block.
Field layout within body:
┌──────────┬───────────┬────────────┬────────────────────────────┐
│ Field ID │ Wire Type │ Name │ Description │
├──────────┼───────────┼────────────┼────────────────────────────┤
│ 1 │ Varint │ lang │ Language enum byte │
│ 2 │ Bytes │ path │ UTF-8 file path │
│ 3 │ Bytes │ content │ Raw source code bytes │
│ 4 │ Varint │ line_start │ Start line (optional) │
│ 5 │ Varint │ line_end │ End line (optional) │
└──────────┴───────────┴────────────┴────────────────────────────┘Fields 4 and 5 are optional — they are only encoded when line_range
is Some. This lets you represent either a full file or a specific
line range within it.
Fields§
§lang: Lang§path: String§content: Vec<u8>§line_range: Option<(u32, u32)>Optional line range (start, end) for code fragments.
Both values are 1-indexed and inclusive.
Implementations§
Trait Implementations§
impl Eq for CodeBlock
impl StructuralPartialEq for CodeBlock
Auto Trait Implementations§
impl Freeze for CodeBlock
impl RefUnwindSafe for CodeBlock
impl Send for CodeBlock
impl Sync for CodeBlock
impl Unpin for CodeBlock
impl UnsafeUnpin for CodeBlock
impl UnwindSafe for CodeBlock
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