Skip to main content

Interface

Struct Interface 

Source
pub struct Interface {
    pub groups: Groups,
    pub derived: Derived,
}
Expand description

A config interface’s declaration and derived types: everything a writer and a reader of its wire need from its contract.

Fields§

§groups: Groups§derived: Derived

Implementations§

Source§

impl Interface

Source

pub fn read( annotation: &Json, files: &[(&str, &Json)], ) -> Result<Self, Vec<Invalid>>

Reads a declaration against its packed files, and derives its types.

§Errors

Groups::read’s reasons.

Source

pub fn of(contract: &Contract) -> Result<Self, Unread>

A contract’s config interface: its state config’s config.groups. A reader MUST NOT read a record by a contract whose lint has a finding (§2.2); lint_contract says.

§Errors

Unread.

Source

pub fn schema(&self, writable: &BTreeSet<String>) -> Schema

config.v1’s schema of the groups (§2.1, Groups::schema).

Source§

impl Interface

Source

pub fn fields(&self, s: &State) -> Json

A record’s JSON reading (core §7.6): its fields by name, an absent optional field no member, a time in milliseconds since the Unix epoch.

Source

pub fn write_record( &self, s: &State, epoch: i64, ) -> Result<Record, WriteRefusal>

Writes a record under the deployment epoch, in seconds (§2.3).

§Errors

The packed writer’s refusal: a value outside its field, a time before the epoch or past its 32 bits.

Source

pub fn read_record( &self, tag: u8, bytes: &[u8], epoch: i64, ) -> Result<State, RecordRefusal>

Reads a record under its CH’s tag and the deployment epoch, refusing it for the first of §2.3’s checks that applies.

§Errors

The RecordRefusal.

Source

pub fn state_of(&self, fields: &Json) -> Result<State, RecordRefusal>

A record’s JSON reading read as a State, with §2.3’s checks after core §7.6’s: group, pending, last, desired, then parameter.

§Errors

The first RecordRefusal that applies.

Source§

impl Interface

Source

pub fn decode_set( &self, group: &str, payload: &[u8], ) -> Option<Result<(Set, Json), RequestRefusal>>

A set/<group>’s query payload read as its Set<T>, with the request’s JSON reading; None for a group with no set, which no queryable answers (§2.4).

§Errors

The RequestRefusal.

Source

pub fn encode_set(&self, group: &str, s: &Set) -> Result<Vec<u8>, WriteRefusal>

A set/<group>’s query payload: CH, then Set<T>’s record.

§Errors

The packed writer’s refusal; packed::WriteRefusal::Unknown for a group with no set.

Source

pub fn decode_control(&self, payload: &[u8]) -> Result<Control, RequestRefusal>

A control operation’s query payload read as its Control.

§Errors

The RequestRefusal.

Source

pub fn encode_control(&self, c: &Control) -> Result<Vec<u8>, WriteRefusal>

A control operation’s query payload.

§Errors

The packed writer’s refusal.

Source

pub fn log_set(&self, group: &str, fields: &Json) -> Json

A set’s request as a log line may carry it (§2.15): its JSON reading, each sensitive parameter’s value written REDACTED.

Source§

impl Interface

Source

pub fn value( &self, state: &State, stamp: Stamp, epoch: i64, ) -> Result<Reply, WriteRefusal>

The record’s value form: a reply’s payload under the as-of mark.

§Errors

Interface::write_record’s.

Source

pub fn error(&self, r: &Refusal, stamp: Stamp) -> Reply

A refusal’s error form (§2.5): Error’s tag, the as-of mark, the code and unavailable’s cause config; with app, an Error detail and the device’s words, where §2.15 lets them be carried.

Trait Implementations§

Source§

impl Clone for Interface

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 Interface

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Forget for Interface

§

impl Freeze for Interface
where *const u8 is !null: Freeze, PhantomData<Entry>: Freeze, PhantomData<(String, TypeDecl)>: Freeze, *const LeafNode<String, Layout> is !null: Freeze, PhantomData<(Owned, LeafOrInternal)>: Freeze, PhantomData<Box<(String, Layout)>>: Freeze, *const LeafNode<String, String> is !null: Freeze, PhantomData<Box<(String, String)>>: Freeze,

§

impl Move for Interface

§

impl RefUnwindSafe for Interface

§

impl Send for Interface
where RawVecInner: Send, &'static str: Send, NodeRef<Owned, String, Layout, LeafOrInternal>: Send, BoxRaw<(String, Layout)>: Send, NodeRef<Owned, String, String, LeafOrInternal>: Send, BoxRaw<(String, String)>: Send,

§

impl Sync for Interface
where RawVecInner: Sync, NodeRef<Owned, String, Layout, LeafOrInternal>: Sync, BoxRaw<(String, Layout)>: Sync, NodeRef<Owned, String, String, LeafOrInternal>: Sync, BoxRaw<(String, String)>: Sync,

§

impl Unpin for Interface
where *const u8 is !null: Unpin, &'static str: Unpin, *const LeafNode<String, Layout> is !null: Unpin, Box<(String, Layout)>: Unpin, *const LeafNode<String, String> is !null: Unpin, Box<(String, String)>: Unpin,

§

impl UnsafeUnpin for Interface

§

impl UnwindSafe for Interface

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> AsNode<T> for T

Source§

fn as_node(&self) -> &T

Source§

impl<T> AsNodeMut<T> for T

Source§

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

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. 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.