pub struct Runtime<C> { /* private fields */ }
Expand description
An instance of a policy with builtins and entrypoints resolved, but with no data provided yet
Implementations§
Source§impl Runtime<DefaultContext>
impl Runtime<DefaultContext>
Sourcepub async fn new<T: Send + 'static>(
store: impl AsContextMut<Data = T>,
module: &Module,
) -> Result<Self>
pub async fn new<T: Send + 'static>( store: impl AsContextMut<Data = T>, module: &Module, ) -> Result<Self>
Load a new WASM policy module into the given store, with the default evaluation context.
§Errors
It will raise an error if one of the following condition is met:
- the provided
wasmtime::Store
isn’t an async one - the
wasmtime::Module
was created with a differentwasmtime::Engine
than thewasmtime::Store
- the WASM module is not a valid OPA WASM compiled policy, and lacks some of the exported functions
- it failed to load the entrypoints or the builtins list
Source§impl<C> Runtime<C>
impl<C> Runtime<C>
Sourcepub async fn new_with_evaluation_context<T: Send + 'static>(
store: impl AsContextMut<Data = T>,
module: &Module,
context: C,
) -> Result<Self>where
C: EvaluationContext,
pub async fn new_with_evaluation_context<T: Send + 'static>(
store: impl AsContextMut<Data = T>,
module: &Module,
context: C,
) -> Result<Self>where
C: EvaluationContext,
Load a new WASM policy module into the given store, with a given evaluation context.
§Errors
It will raise an error if one of the following condition is met:
- the provided
wasmtime::Store
isn’t an async one - the
wasmtime::Module
was created with a differentwasmtime::Engine
than thewasmtime::Store
- the WASM module is not a valid OPA WASM compiled policy, and lacks some of the exported functions
- it failed to load the entrypoints or the builtins list
Sourcepub async fn without_data<T: Send>(
self,
store: impl AsContextMut<Data = T>,
) -> Result<Policy<C>>
pub async fn without_data<T: Send>( self, store: impl AsContextMut<Data = T>, ) -> Result<Policy<C>>
Instanciate the policy with an empty data
object
§Errors
If it failed to load the empty data object in memory
Sourcepub async fn with_data<V: Serialize, T: Send>(
self,
store: impl AsContextMut<Data = T>,
data: &V,
) -> Result<Policy<C>>
pub async fn with_data<V: Serialize, T: Send>( self, store: impl AsContextMut<Data = T>, data: &V, ) -> Result<Policy<C>>
Instanciate the policy with the given data
object
§Errors
If it failed to serialize and load the data
object
Sourcepub fn default_entrypoint(&self) -> Option<&str>
pub fn default_entrypoint(&self) -> Option<&str>
Get the default entrypoint of this module. May return None
if no
entrypoint with ID 0 was found
Sourcepub fn entrypoints(&self) -> HashSet<&str>
pub fn entrypoints(&self) -> HashSet<&str>
Get the list of entrypoints found in this module.
Sourcepub fn abi_version(&self) -> AbiVersion
pub fn abi_version(&self) -> AbiVersion
Get the ABI version detected for this module
Trait Implementations§
Auto Trait Implementations§
impl<C> Freeze for Runtime<C>
impl<C> !RefUnwindSafe for Runtime<C>
impl<C> Send for Runtime<C>where
C: Send,
impl<C> Sync for Runtime<C>where
C: Send,
impl<C> Unpin for Runtime<C>
impl<C> !UnwindSafe for Runtime<C>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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