Skip to main content

ExchangeRecord

Struct ExchangeRecord 

Source
pub struct ExchangeRecord {
Show 24 fields pub schema: String, pub protocol: String, pub binding: ArtifactId, pub members: Vec<ExchangeMember>, pub request_digest: Option<String>, pub response_digest: Option<String>, pub bytes_sent: bool, pub status: Option<u16>, pub retry_after: Option<String>, pub requested_model: Option<String>, pub served: ServedIdentity, pub route: Vec<String>, pub generation_id: Option<String>, pub usage: BTreeMap<String, u64>, pub reported_cost: Option<ReportedCost>, pub exchange_charge: Charge, pub attribution: Attribution, pub privacy_requested: BTreeMap<String, String>, pub provider_extras: BTreeMap<String, String>, pub late: bool, pub truncated: bool, pub principal: Option<PrincipalEvidence>, pub phase_expiry: Option<PhaseExpiry>, pub connection: Option<ConnectionObservation>,
}
Expand description

One exchange, keyed by the attempt ids it served (spec 009, 3.9.1). Bounded: every string is cut to MAX_TEXT_BYTES and every collection to its cap by ExchangeRecord::bounded, so a record never exceeds EXCHANGE_V1’s max_bytes. Request and response bytes are never in the record; only their digests are.

Fields§

§schema: String§protocol: String

The wire protocol: PROTOCOL or a foreign mapping’s own label.

§binding: ArtifactId

The adapter binding identity (the adapter’s artifact, 3.2.3).

§members: Vec<ExchangeMember>

Every member attempt, in attempt-id order.

§request_digest: Option<String>

sha256: digest of the request bytes, when any were built.

§response_digest: Option<String>

sha256: digest of the response bytes, when any were read.

§bytes_sent: bool

Whether any request byte left the process.

§status: Option<u16>§retry_after: Option<String>

Recorded verbatim, never slept on.

§requested_model: Option<String>§served: ServedIdentity§route: Vec<String>§generation_id: Option<String>§usage: BTreeMap<String, u64>

Usage as reported (for example token counts), by name.

§reported_cost: Option<ReportedCost>

Cost as reported, verbatim; units are not money.

§exchange_charge: Charge

The exchange’s charge in deployment units, before attribution.

§attribution: Attribution§privacy_requested: BTreeMap<String, String>§provider_extras: BTreeMap<String, String>

Provider-reported extras (3.5.5): argmax, confidence, explanations.

§late: bool

The response arrived after the attempts stopped waiting; nothing in it was supplied (3.4.4).

§truncated: bool

Something was cut to fit the record’s bounds.

§principal: Option<PrincipalEvidence>

The digest and mapping version of the principal reference the request carried (spec 020, 3.6); absent when none was sent.

§phase_expiry: Option<PhaseExpiry>

The transport phase that ran out, when an enabled phase policy governed the exchange (spec 020, 3.4). Absent otherwise, so a record without one keeps its spec 009 bytes.

§connection: Option<ConnectionObservation>

The pooled connection the exchange used (spec 020, 3.5); absent when connection reuse is disabled.

Implementations§

Source§

impl ExchangeRecord

Source

pub fn bounded(self) -> Self

The record cut to its fixed bounds: every string to MAX_TEXT_BYTES, members to MAX_ITEMS, route to MAX_ROUTE and each map to MAX_ENTRIES, with truncated set when anything was cut. The schema is set.

Source

pub fn is_bounded(&self) -> bool

True when the record is within its bounds, as Self::bounded leaves it. A parsed record that is not is refused by Self::parse_checked.

Source

pub fn parse_checked(bytes: &[u8]) -> Result<Self, DocumentError>

Parse under EXCHANGE_V1 and refuse a record beyond its bounds.

Trait Implementations§

Source§

impl Clone for ExchangeRecord

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 ExchangeRecord

Source§

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

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

impl<'de> Deserialize<'de> for ExchangeRecord

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 Document for ExchangeRecord

Source§

const SCHEMA: &'static str = schema::REMOTE_EXCHANGE

The schema string this document carries (spec 002, 3.2.1).
Source§

const LIMITS: ParseLimits = EXCHANGE_V1

The limit set its bytes are scanned against (spec 002, 3.2.5).
Source§

fn schema(&self) -> &str

The value of the document’s own schema field.
Source§

fn parse(bytes: &[u8]) -> Result<Self, DocumentError>

Scan, deserialize and check the schema string.
Source§

fn canonical(&self) -> Result<Vec<u8>, CanonicalError>

The canonical bytes (spec 002, 3.3.1).
Source§

fn record_canonical(&self) -> Result<Vec<u8>, CanonicalError>
where Self: PartialEq,

The record canonical bytes (spec 004, 5.6): the canonical bytes, with finite fractional numbers written in shortest round-trip form.
Source§

fn record_digest(&self) -> Result<ContentDigest, CanonicalError>
where Self: PartialEq,

sha256(SCHEMA || 0x00 || record canonical bytes) (spec 004, 3.1.6). Equal to the identity of an identified document.
Source§

impl Eq for ExchangeRecord

Source§

impl JsonSchema for ExchangeRecord

Source§

fn schema_name() -> Cow<'static, str>

The name of the generated JSON Schema. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

fn json_schema(generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn inline_schema() -> bool

Whether JSON Schemas generated for this type should be included directly in parent schemas, rather than being re-used where possible using the $ref keyword. Read more
Source§

impl PartialEq for ExchangeRecord

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 ExchangeRecord

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 ExchangeRecord

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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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