Skip to main content

OperationSchema

Struct OperationSchema 

Source
pub struct OperationSchema {
    pub name: &'static str,
    pub params: &'static [HostType],
    pub variadic: bool,
    pub result: HostType,
    pub capability: &'static str,
    pub effect: Effect,
    pub cancellable: bool,
    pub recordable: bool,
    pub result_is_task_safe: bool,
}
Expand description

One operation of one host module.

Every field is read by something: HostRegistry::call checks name and arity before it dispatches, holds a call to params before the host sees it and the host to result after it answers, params and result render the signature a diagnostic shows, capability is the gate, and result_is_task_safe answers the Language Card’s rule for values leaving a host call for a task. cove-sema reads params and result too, at the call site, where a mistake still has a span to point at. effect, cancellable, and recordable are the three ADR 0001 facts whose consumers are named but not yet built — cove replay for recordable, cove impact for effect, and for cancellable, a host that could abandon a call in flight: a cancelled task stops at its next safepoint, which is after the call it is already inside returns.

Fields§

§name: &'static str

The name Cove source calls, such as println.

§params: &'static [HostType]

Parameter types in declaration order.

This is a promise both ends hold a call to rather than a label on it: cove check checks each argument at its call site, and the boundary checks them again for the hosts the checker cannot see.

§variadic: bool

Whether the last parameter is variadic.

Cove writes a variadic parameter items: T... and makes it an immutable Array<T> inside the callee, so it accepts zero or more arguments: a variadic operation’s minimum arity is one less than params.len().

§result: HostType

The type the operation produces.

This is a promise the boundary holds the host to rather than a label on it: HostRegistry checks what the host answered against this before handing it on, so an operation cannot declare one type and produce another. cove_runtime::schema::Admits says how far the check goes.

§capability: &'static str

The capability a host must grant before this operation may be called.

§effect: Effect

Whether the operation reads, writes reversibly, or writes irreversibly.

§cancellable: bool

Whether abandoning a call that is already in flight is meaningful and safe. A wait can be abandoned because nothing has happened yet; a write that has already reached the outside world cannot.

§recordable: bool

Whether the call’s result can be recorded and handed back later without calling the host again, which is what cove replay needs.

An operation that opens a resource is recordable, because ADR 0013 makes a handle a name rather than a live thing: what the trace records is the identity the host issued, and a replay hands the same identity back and answers the calls made on it from the trace too.

§result_is_task_safe: bool

Whether the value this operation produces may cross a task boundary.

The Language Card puts this decision here rather than in the value: “Host resources declare task-safety in their Host API schema.”

Implementations§

Source§

impl OperationSchema

Source

pub fn min_arity(&self) -> usize

The fewest arguments the operation accepts.

Source

pub fn accepts(&self, arity: usize) -> bool

Whether a call with arity arguments has the right number of them.

Source

pub fn param(&self, index: usize) -> Option<&'static HostType>

The type declared for the argument at index.

A variadic operation’s last parameter answers for every argument from its own position onwards, because that is what items: T... means: one declared T and as many arguments of it as the call likes. An index past a fixed operation’s parameters has no declared type, which is an arity mistake and reported as one.

Source

pub fn signature(&self) -> String

The signature, in the form it would be written in Cove source, without the module qualifier: println(String...) -> Result<Unit, Error>.

Source

pub fn expected_arity(&self) -> String

How many arguments this operation takes, phrased for a diagnostic.

Trait Implementations§

Source§

impl Clone for OperationSchema

Source§

fn clone(&self) -> OperationSchema

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 Copy for OperationSchema

Source§

impl Debug for OperationSchema

Source§

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

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

impl Eq for OperationSchema

Source§

impl PartialEq for OperationSchema

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for OperationSchema

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