Skip to main content

Attachment

Enum Attachment 

Source
pub enum Attachment {
    Image {
        id: String,
        width: u32,
        height: u32,
        bytes: String,
    },
    Audio {
        id: String,
        sample_rate: u32,
        bytes: String,
    },
    Video {
        id: String,
        bytes: String,
    },
    Unknown,
}
Expand description

Re-exports of the v2 wire types per ADR 0015. v2 is shipped as part of inferd-client 0.2 so consumers building against v2 can reach the proto types without a separate inferd-proto dep. One binary attachment in the request’s top-level attachments[] table.

Tagged-enum shape: each variant carries exactly the metadata libmtmd (and other engines’ multimodal interfaces) need for that modality. Unknown variants deserialise as Attachment::Unknown so v2.0 clients don’t reject newer payloads at parse time; resolve() rejects them only when they reach validation.

id must be unique within a single request; content blocks reference attachments by exactly this string.

bytes is standard-base64-encoded (RFC 4648, with +/ and = padding). After ~1.33× inflation the raw payload must still leave room within the 64 MiB per-frame cap.

Variants§

§

Image

Decoded RGB image. bytes is width * height * 3 interleaved RGB octets (no alpha channel; consumer drops alpha or composites against a known background before sending).

Fields

§id: String

Caller-chosen identifier; unique within the request.

§width: u32

Image width in pixels.

§height: u32

Image height in pixels.

§bytes: String

Base64 of width * height * 3 interleaved RGB bytes.

§

Audio

Decoded audio PCM. bytes is base64 of n_samples * sizeof(f32) little-endian float32 samples at the named sample rate.

Fields

§id: String

Caller-chosen identifier; unique within the request.

§sample_rate: u32

Sample rate in Hz (e.g. 16000 for Whisper-class encoders; Gemma 4 audio uses its own rate which the daemon learns at adapter init time and reports via BackendCapabilities).

§bytes: String

Base64 of float32 PCM samples (little-endian).

§

Video

Reserved. Engine support is a separate concern; v2.0 daemons reject video attachments with attachment_unsupported until a video-capable adapter ships. Wire shape is intentionally kept stub-thin; future revisions add fields without breaking v2.0 clients (forward-compat: serde will accept extra fields silently).

Fields

§id: String

Caller-chosen identifier; unique within the request.

§bytes: String

Base64 of decoded video frames; precise format TBD.

§

Unknown

Forward-compat escape hatch — any kind value the local build doesn’t recognise lands here so older clients/daemons don’t reject newer payloads at parse time. resolve() rejects them only when they reach validation.

Implementations§

Source§

impl Attachment

Source

pub fn id(&self) -> &str

The attachment’s id (independent of variant).

Returns an empty string for Unknown since unknown variants don’t carry an id field reliably.

Source

pub fn is_image(&self) -> bool

true if this attachment is an image.

Source

pub fn is_audio(&self) -> bool

true if this attachment is audio.

Source

pub fn is_video(&self) -> bool

true if this attachment is video.

Trait Implementations§

Source§

impl Clone for Attachment

Source§

fn clone(&self) -> Attachment

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Attachment

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Attachment

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<Attachment, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Attachment

Source§

fn eq(&self, other: &Attachment) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Attachment

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for Attachment

Source§

impl StructuralPartialEq for Attachment

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,