Skip to main content

Descriptor

Struct Descriptor 

Source
pub struct Descriptor {
    pub format: String,
    pub service: String,
    pub instance: String,
    pub run: Option<String>,
    pub catalog: Option<String>,
    pub interfaces: Vec<InterfaceEntry>,
    pub capabilities: Vec<String>,
    pub requires: Vec<RequireEntry>,
    pub profiles: Vec<String>,
    pub meta: BTreeMap<String, Value>,
}
Expand description

One instance’s descriptor.

Fields§

§format: String

zk2-descriptor/0.1.

§service: String

<system>/<service>.

§instance: String

The instance id: 16 lowercase hex digits.

§run: Option<String>

The run the instance writes under now (core §3.3, §4.3), as its bytes in lowercase hexadecimal: 4 digits for a 16-bit run, 8 for a 32-bit one. An owner states it; a checker reads it as optional, so a descriptor that states none is not D000, and any other spelling is D002. Never null.

§catalog: Option<String>

The id of the deployment catalog the instance writes under (core §3.3, §8.6), as 8 lowercase hex digits. An owner given a catalog states it, and one with none leaves it out; a checker reads it as optional, and any other spelling is D002. Never null.

§interfaces: Vec<InterfaceEntry>

The interfaces this instance implements.

§capabilities: Vec<String>

The capabilities this instance holds, naming the capability: gates of its contracts. Written only when one is held: absent is none (§3.3).

§requires: Vec<RequireEntry>

Every requirement, with its bindings as declared (R3). Written only when there is one: absent is none.

§profiles: Vec<String>

The profiles this instance follows, as <name>.v<major>. Written only when it follows one: absent is none.

§meta: BTreeMap<String, Value>

Host, process, build: informative, never interpreted. zid is the owner’s session zid, which an owner SHOULD state: a tool attributes a state stamp to the owner by it (§3.3, 0.10; S1). Written only when it holds a member.

Implementations§

Source§

impl Descriptor

Source

pub fn size_of(&self, served: &[u8]) -> Size

The size of served, the document this descriptor’s owner put and answers, as the owner wrote it (core §3.3): its count of bytes, and the rest, which is that count less each of interfaces, capabilities, requires and profiles the descriptor states.

A member is counted from the opening quote of its name to the last byte of its value, and one comma with it. A member taken out of an object that keeps another takes exactly one comma with it, wherever it stands, and format, service and instance are always written. So the rest is exact for the compact form the reference writes, every empty member left out. A member’s value is counted as it serializes here, so the rest of a document its owner spaced otherwise counts that member’s spacing too.

Nothing here can fail: a value that does not serialize counts for nothing, and the rest never falls below 0.

Source

pub fn size(&self) -> Result<Size, Error>

This descriptor’s size as it serializes here (Descriptor::size_of over its compact JSON, every empty member left out): what an owner that has not written it yet would serve.

§Errors

The descriptor does not serialize.

Source

pub fn stated_run(&self) -> Option<Run>

The run the descriptor states (core §3.3), None when it states none or spells it otherwise than 4 or 8 lowercase hex digits (D002).

Source

pub fn stated_catalog(&self) -> Option<CatalogId>

The catalog the descriptor names (core §3.3, §8.6), None when it names none or spells it otherwise than 8 lowercase hex digits (D002).

Source

pub fn exposed<'c>(&self, contract: &'c Contract) -> Option<Vec<&'c Resource>>

The resources of contract this instance exposes (§3.3): the contract’s, minus the optional ones gated on a capability it does not hold, minus those its entry lists unavailable; none at all when the entry marks the interface "standby": true (§3.3, §6, 0.39), whose unavailable says what it will expose once it serves. None when it lists no entry for the contract’s interface.

What a tool decides a split-brain from, beside replicated serving (§6, 0.7, #660). The entry’s revision is the caller’s to match: this reads contract as given.

Trait Implementations§

Source§

impl Clone for Descriptor

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 Descriptor

Source§

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

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

impl<'de> Deserialize<'de> for Descriptor

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 JsonSchema for Descriptor

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 Descriptor

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 Descriptor

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 Descriptor

Auto Trait Implementations§

§

impl Forget for Descriptor

§

impl Freeze for Descriptor

§

impl Move for Descriptor

§

impl RefUnwindSafe for Descriptor

§

impl Send for Descriptor
where RawVecInner: Send, NodeRef<Owned, String, u64, LeafOrInternal>: Send, BoxRaw<(String, u64)>: Send, NodeRef<Owned, String, String, LeafOrInternal>: Send, BoxRaw<(String, String)>: Send, NodeRef<Owned, String, Value, LeafOrInternal>: Send, BoxRaw<(String, Value)>: Send,

§

impl Sync for Descriptor
where RawVecInner: Sync, NodeRef<Owned, String, u64, LeafOrInternal>: Sync, BoxRaw<(String, u64)>: Sync, NodeRef<Owned, String, String, LeafOrInternal>: Sync, BoxRaw<(String, String)>: Sync, NodeRef<Owned, String, Value, LeafOrInternal>: Sync, BoxRaw<(String, Value)>: Sync,

§

impl Unpin for Descriptor
where *const u8 is !null: Unpin, *const LeafNode<String, u64> is !null: Unpin, Box<(String, u64)>: Unpin, *const LeafNode<String, String> is !null: Unpin, Box<(String, String)>: Unpin, *const LeafNode<String, Value> is !null: Unpin, Box<(String, Value)>: Unpin,

§

impl UnsafeUnpin for Descriptor

§

impl UnwindSafe for Descriptor

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