Skip to main content

Envelope

Struct Envelope 

Source
#[non_exhaustive]
pub struct Envelope { pub result: ResultBlock, pub meta: Map<String, Value>, pub clusters: Vec<Cluster>, pub page: Page, pub cache: EnvelopeCache, }
Expand description

Top-level envelope (§7).

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§result: ResultBlock

Result-level metadata: totals, axes, detection report.

§meta: Map<String, Value>

Free-form metadata block. Defaults to empty.

§clusters: Vec<Cluster>

Top-level clusters (root children).

§page: Page

Page block — populated when --cluster is set, empty otherwise.

§cache: EnvelopeCache

Optional source records cache used when re-processing a saved envelope. Empty for hand-authored/minimal envelopes.

Implementations§

Source§

impl Envelope

Source

pub fn looks_like_envelope(prefix: &[u8]) -> bool

§9: detect whether a byte prefix starts with a face envelope.

The check walks the prefix as a structural scan: skip BOM and leading whitespace, require an opening {, then look at the top-level keys (depth-1 strings). If both result and clusters appear before the prefix runs out, return true.

This is intentionally a structural scan, not a full serde_json::from_slice, so the §9 self-consume detection works on envelopes larger than the sniff prefix (the prefix is only ~4 KiB; an envelope’s meta block alone may exceed that). A truncated prefix that contains both target keys at depth 1 is enough to classify the input.

Returns false for any input that does not start with a JSON object (JSONL streams, JSON arrays, CSV/TSV, scalars).

§Examples
use face_core::Envelope;

let env = br#"{"result":{"input_total":0},"clusters":[]}"#;
assert!(Envelope::looks_like_envelope(env));

let arr = b"[1, 2, 3]";
assert!(!Envelope::looks_like_envelope(arr));

Trait Implementations§

Source§

impl Clone for Envelope

Source§

fn clone(&self) -> Envelope

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 Envelope

Source§

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

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

impl Default for Envelope

Source§

fn default() -> Envelope

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Envelope

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 Envelope

Source§

fn eq(&self, other: &Envelope) -> 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 Envelope

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 Envelope

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> 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, 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.