Jam

Struct Jam 

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

JAM environment

Implementations§

Source§

impl Jam

Source

pub fn add_account(&mut self, service: ServiceId, account: ServiceAccount)

Add a service account

Source

pub fn add_service(&mut self, service: ServiceId, code: Vec<u8>)

Add a service account

Source

pub fn add_preimage( &mut self, service: ServiceId, preimage: Vec<u8>, ) -> OpaqueHash

Add a preimage to the service account

Source

pub fn get_storage<V: DeserializeOwned>( &self, service: ServiceId, key: &[u8], ) -> Option<V>

Get a storage of an account

Source

pub fn set_code(&mut self, service: ServiceId, code: OpaqueHash)

Set the code of the service account

Source

pub fn mint(&mut self, service: ServiceId, amount: u64)

Mint balance to a service account

Source

pub fn with_account(self, service: ServiceId, account: ServiceAccount) -> Self

Add a service account

Source§

impl Jam

Source

pub fn with_auth(self, service: ServiceId, code: Vec<u8>) -> Self

Set the authorization

Source

pub fn with_auth_token(self, token: Vec<u8>) -> Self

Set the authorization token

Source

pub fn with_auth_config(self, config: Vec<u8>) -> Self

Set the authorizer config

Source

pub fn with_authorizer(self, auth: Auth) -> Self

Set the authorization

Source§

impl Jam

Source

pub fn add_item(&mut self, item: WorkItem)

Add a work item

TODO: validate the work item

Source

pub fn build(&mut self) -> Result<WorkPackage>

Build a work package

Source

pub fn pack(&mut self, service: ServiceId, payload: Vec<u8>) -> Result<()>

pack a work item

Source

pub fn send( &mut self, service: ServiceId, payload: Vec<u8>, ) -> Result<WorkPackage>

Send a work package

Source§

impl Jam

Source

pub fn execute( &mut self, service: ServiceId, payload: Vec<u8>, ) -> Result<ExecutionInfo>

Execute a work item directly

TODO: introduce better execution result

Source

pub fn authorize( &mut self, work: &WorkPackage, core_idx: u16, ) -> Result<Executed>

Authorize the work package

Source

pub fn refine(&mut self, work: &WorkPackage) -> Result<Vec<WorkResult>>

Refine the work package

NOTE: run refine for all work items

Source

pub fn accumulate( &mut self, results: Vec<WorkResult>, ) -> Result<Vec<Accumulated>>

Accumulate the work package

  1. convert work package to work report
  2. run accumulate for all work items
  3. return the accumulated result

Trait Implementations§

Source§

impl Default for Jam

Source§

fn default() -> Jam

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

Auto Trait Implementations§

§

impl Freeze for Jam

§

impl RefUnwindSafe for Jam

§

impl Send for Jam

§

impl Sync for Jam

§

impl Unpin for Jam

§

impl UnwindSafe for Jam

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