pub struct ImageBlock {
pub media_type: MediaType,
pub alt_text: String,
pub data: Vec<u8>,
}Expand description
IMAGE block — image content or reference.
Can carry either inline image bytes or a URI pointing to an external
image. The media_type field tells the decoder how to interpret the
data payload (PNG, JPEG, SVG, etc.).
Field layout within body:
┌──────────┬───────────┬────────────┬──────────────────────────┐
│ Field ID │ Wire Type │ Name │ Description │
├──────────┼───────────┼────────────┼──────────────────────────┤
│ 1 │ Varint │ media_type │ MediaType enum byte │
│ 2 │ Bytes │ alt_text │ Alt text description │
│ 3 │ Bytes │ data │ Image bytes or URI │
└──────────┴───────────┴────────────┴──────────────────────────┘Fields§
§media_type: MediaType§alt_text: String§data: Vec<u8>Raw image bytes (inline) or a UTF-8 URI string (reference).
The block’s IS_REFERENCE flag in BlockFlags distinguishes
between inline data and a URI reference.
Implementations§
Source§impl ImageBlock
impl ImageBlock
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 an IMAGE block from a TLV-encoded body.
Trait Implementations§
Source§impl Clone for ImageBlock
impl Clone for ImageBlock
Source§fn clone(&self) -> ImageBlock
fn clone(&self) -> ImageBlock
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 ImageBlock
impl Debug for ImageBlock
Source§impl PartialEq for ImageBlock
impl PartialEq for ImageBlock
impl Eq for ImageBlock
impl StructuralPartialEq for ImageBlock
Auto Trait Implementations§
impl Freeze for ImageBlock
impl RefUnwindSafe for ImageBlock
impl Send for ImageBlock
impl Sync for ImageBlock
impl Unpin for ImageBlock
impl UnsafeUnpin for ImageBlock
impl UnwindSafe for ImageBlock
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