Skip to main content

ArtifactPreview

Enum ArtifactPreview 

Source
pub enum ArtifactPreview {
    Text {
        text: String,
        truncated: bool,
        source_bytes: u64,
    },
    Json {
        value: Value,
        source_bytes: u64,
    },
    Image {
        format: String,
        width: u32,
        height: u32,
        thumb_width: u32,
        thumb_height: u32,
        pixels_ppm_hex: String,
    },
    Audio {
        format: String,
        duration_ms: u64,
        sample_rate: u32,
        channels: u16,
        frames: u64,
        peaks: Vec<u16>,
    },
    Empty {
        reason: String,
    },
}
Expand description

What a read derived from the bytes — the RegistryDiff precedent applied to media: computed on read, never stored. A stored preview would be a second, divergent account of the same bytes; derivation keeps one source of truth, and a kind that cannot be derived answers ArtifactPreview::Empty — an honest empty, not a placeholder.

The derivations are deliberately dependency-free, which bounds what they cover, stated per kind:

  • file / data: a bounded UTF-8 window (ArtifactPreview::Text), or the parsed document when the whole payload fits the window and is JSON (ArtifactPreview::Json). Binary bytes are not text — they answer Empty.
  • image: a real downscaled thumbnail (ArtifactPreview::Image) for the formats decodable without a codec dependency — uncompressed BMP (24/32-bit BI_RGB) and binary PNM (P6/P5). Compressed formats (PNG, JPEG, GIF, …) answer Empty: a codec dependency is the measured-need seam the design’s preview question reserves, not something to half-parse.
  • audio: waveform metadata (ArtifactPreview::Audio) for RIFF/WAVE PCM (8/16-bit) — duration, rate, channels, and a bounded peak envelope. Anything else answers Empty.

Variants§

§

Text

A bounded UTF-8 window over the source bytes.

Fields

§text: String

The window’s text (lossless: only whole characters).

§truncated: bool

Whether the source extends past the window.

§source_bytes: u64

The source size in bytes.

§

Json

The parsed JSON document (only when it fits the window whole — a preview is bounded, so a larger document degrades to Text, never to a partial parse).

Fields

§value: Value

The parsed document.

§source_bytes: u64

The source size in bytes.

§

Image

A downscaled thumbnail, re-encoded as a binary PPM (P6) and carried hex-encoded (the repo’s dependency-free byte-on-JSON codec — the commit path’s bytes_hex convention).

Fields

§format: String

The decoded source format (bmp or pnm).

§width: u32

The source dimensions.

§height: u32

The source dimensions.

§thumb_width: u32

The thumbnail dimensions (integer-factor downscale, nearest sampling).

§thumb_height: u32

The thumbnail dimensions.

§pixels_ppm_hex: String

The thumbnail as a P6 PPM, hex-encoded.

§

Audio

Waveform metadata for RIFF/WAVE PCM: the envelope an operator glances at, derived — the audio bytes themselves are never re-encoded.

Fields

§format: String

The decoded container (wav).

§duration_ms: u64

The clip length in whole milliseconds.

§sample_rate: u32

The sample rate in Hz.

§channels: u16

The channel count.

§frames: u64

The frame count (samples per channel).

§peaks: Vec<u16>

The peak envelope: PREVIEW_WAVEFORM_BUCKETS buckets, each the loudest absolute sample in its window on the 16-bit scale (0..=65535), max across channels.

§

Empty

The honest empty answer: this media kind (or these bytes, under the dependency-free derivations above) yields no preview. Carries the reason so the answer is attributable, never a placeholder.

Fields

§reason: String

Why nothing was derivable.

Trait Implementations§

Source§

impl Clone for ArtifactPreview

Source§

fn clone(&self) -> Self

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 ArtifactPreview

Source§

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

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

impl<'de> Deserialize<'de> for ArtifactPreview

Source§

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

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

impl PartialEq for ArtifactPreview

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl Serialize for ArtifactPreview

Source§

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

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

impl StructuralPartialEq for ArtifactPreview

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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 = !

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

fn try_from(value: U) -> Result<T, !>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more