Struct brane_cli::vm::OfflineVm

source ·
pub struct OfflineVm { /* private fields */ }
Expand description

Defines a VM that has no online interaction and does everything locally.

Implementations§

source§

impl OfflineVm

source

pub fn new( docker_opts: DockerOptions, keep_containers: bool, package_dir: impl Into<PathBuf>, dataset_dir: impl Into<PathBuf>, results_dir: impl Into<PathBuf>, package_index: Arc<PackageIndex>, data_index: Arc<DataIndex>, ) -> Self

Constructor for the OfflineVm that initializes it with the initial state.

§Arguments
  • docker_opts: The information we need to connect to the local Docker daemon.
  • keep_containers: Whether to keep containers after execution completes or not.
  • package_dir: The directory where packages (and thus images) are stored.
  • dataset_dir: The directory where datasets (and thus committed results) are stored.
  • results_dir: The directory where temporary results are stored.
  • package_index: The PackageIndex to use to resolve packages.
  • data_index: The DataIndex to use to resolve data indices.
§Returns

A new OfflineVm instance with one coherent state.

source

pub async fn exec(self, workflow: Workflow) -> (Self, Result<FullValue, Error>)

Runs the given workflow on this VM.

There is a bit of ownership awkwardness going on, but that’s due to the need for the struct to outlive threads.

§Arguments
  • workflow: The Workflow to execute.
§Returns

The result of the workflow, if any. It also returns self again for subsequent runs.

source

pub fn results_dir(&self) -> PathBuf

Returns the path to the internal temporary folder for results.

Trait Implementations§

source§

impl Vm for OfflineVm

source§

type GlobalState = GlobalState

The type of the thread-global extension to the runtime state.
source§

type LocalState = ()

The type of the thread-local extension to the runtime state.
source§

fn store_state( this: &Arc<RwLock<Self>>, state: RunState<Self::GlobalState>, ) -> Result<(), Error>

A function that stores the given runtime state information in the parent struct. Read more
source§

fn load_state( this: &Arc<RwLock<Self>>, ) -> Result<RunState<Self::GlobalState>, Error>

A function that returns the VM’s runtime state in the parent struct. Read more
source§

fn new_state(custom: Self::GlobalState) -> RunState<Self::GlobalState>

Initializes a new global state based on the given custom part. Read more
source§

fn run<'life0, 'async_trait, P>( this: Arc<RwLock<Self>>, snippet: Workflow, prof: ProfileScopeHandle<'life0>, ) -> Pin<Box<dyn Future<Output = Result<FullValue, VmError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: Sync + Send + 'async_trait, P: 'async_trait + VmPlugin<GlobalState = Self::GlobalState, LocalState = Self::LocalState>,

Runs the given workflow, possibly asynchronously (if a parallel is encountered / there are external functions calls and the given closure runs this asynchronously.) Read more

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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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

source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
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<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

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
source§

impl<T> ErasedDestructor for T
where T: 'static,

source§

impl<T> MaybeSendSync for T