Skip to main content

Agent

Struct Agent 

Source
pub struct Agent { /* private fields */ }
Expand description

One agent: an owner of lanes, channels, capabilities and promises.

Implementations§

Source§

impl Agent

Source

pub fn new() -> Self

Create an agent kernel with an unpredictable capability secret.

The secret comes from the operating system’s CSPRNG. A clock-derived seed would make capability ids guessable to a peer that can estimate the start time, which defeats unforgeability.

Source

pub fn with_secret(secret: [u8; 32]) -> Self

Create an agent with a fixed secret (tests, deterministic replays).

Source

pub fn cell(&self) -> &KernelCell

The shared cell, for transports and adapters that need direct access.

Source

pub fn register(&self, provider: Box<dyn Provider>) -> ProviderId

Register a provider and return its id.

Source

pub fn set_latency(&self, latency_ms: u64)

Configure the simulated provider latency (milliseconds per batch).

Source

pub fn mint( &self, provider: ProviderId, object: u64, attrs: CapAttrs, ) -> Result<CapHandle>

Mint a first-generation capability.

Source

pub fn attenuate( &self, parent: &CapHandle, attrs: CapAttrs, ) -> Result<CapHandle>

Attenuate a capability. Refuses any widening.

Source

pub fn import(&self, id: CapId) -> CapHandle

Import a capability id without owning a reference.

This is how a peer handle is reconstructed from the wire: the id must already exist in this kernel, otherwise the first call fails with rpc/unknown-capability. Importing never proves authority; the registry does.

Source

pub fn revoke(&self, cap: &CapHandle)

Revoke a capability and every capability derived from it.

Source

pub fn create_lane( &self, name: impl Into<String>, budget: Budget, ) -> Result<LaneId>

Create a lane.

Source

pub fn attenuate_lane(&self, lane: LaneId, budget: Budget) -> Result<()>

Attenuate a lane’s budget.

Source

pub fn destroy_lane(&self, lane: LaneId) -> Result<()>

Destroy a lane and drop its queued work.

Queued jobs are removed from the dispatch queue and their promises are rejected, so a destroyed lane cannot keep spending budget or produce side effects after the fact.

Source

pub fn create_channel( &self, name: impl Into<String>, direction: Direction, ) -> Result<ChannelId>

Create a channel.

Source

pub fn subscribe(&self, lane: LaneId, channel: ChannelId) -> Result<()>

Subscribe a lane to a channel.

Source

pub fn send( &self, lane: LaneId, channel: ChannelId, payload: Value, caps: &[CapHandle], ) -> Result<u64>

Send a message, transferring capabilities with it.

Source

pub fn recv(&self, channel: ChannelId) -> Result<Option<Message>>

Receive the next message on a channel.

Source

pub fn call( &self, lane: LaneId, cap: &CapHandle, method: &str, args: Vec<Arg>, ) -> Result<PromiseHandle>

Issue a call. The returned promise is pending until the kernel runs.

Source

pub fn run(&self) -> u64

Run until no job is queued. Returns the number of provider round-trips.

Source

pub fn round_trips(&self) -> u64

Round-trips observed so far.

Source

pub fn await_promise(&self, promise: &PromiseHandle) -> Result<Value>

Await a promise, running the kernel until it settles.

Source

pub fn resolve(&self, promise: &PromiseHandle, value: Value) -> Result<()>

Resolve a pending promise manually (used by peers that answer out of band).

Source

pub fn cancel(&self, promise: &PromiseHandle) -> Result<()>

Cancel a promise.

A job that has not been dispatched yet is removed from the queue, so a cancellation really prevents the provider call (and its side effects). A job already in flight cannot be stopped; its result is discarded.

Source

pub fn take_drops(&self, provider: ProviderId) -> Vec<(u64, CapId)>

Drain drop notifications recorded by one provider.

Source

pub fn events(&self) -> Vec<Event>

The event log.

Source

pub fn lane(&self, lane: LaneId) -> Result<Lane>

Lane statistics.

Source

pub fn channel(&self, channel: ChannelId) -> Result<Channel>

Channel statistics.

Source

pub fn cap_attrs(&self, cap: &CapHandle) -> Result<CapAttrs>

Capability attributes, for tests and policy tooling.

Trait Implementations§

Source§

impl Clone for Agent

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 Default for Agent

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl !RefUnwindSafe for Agent

§

impl !Send for Agent

§

impl !Sync for Agent

§

impl !UnwindSafe for Agent

§

impl Freeze for Agent

§

impl Unpin for Agent

§

impl UnsafeUnpin for Agent

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

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more