Skip to main content

ComponentManager

Struct ComponentManager 

Source
pub struct ComponentManager { /* private fields */ }

Implementations§

Source§

impl ComponentManager

Source

pub fn from_lock( lock: ComponentLock, cache_root: impl Into<PathBuf>, target: impl Into<String>, host: AlefHostApiV1, ) -> Result<Self, ComponentError>

Source

pub fn offline(self, offline: bool) -> Self

Disable network downloads: Self::ensure_contract and Self::prefetch fail a missing artifact with ComponentError::Offline instead of attempting a request. An artifact already cached on disk is unaffected. Generated bindings call this when the crate-specific {CRATE}_COMPONENT_OFFLINE environment variable is set.

Source

pub fn ensure_contract( &self, component_id: &str, contract_name: &str, entry_symbol: &[u8], ) -> Result<Arc<LoadedComponent>, ComponentError>

Load one contract a component provides.

entry_symbol is that contract’s NUL-terminated producer entry-point symbol (alef::codegen::component::entry_point_symbol); the caller supplies it because computing it requires the same identifier-casing logic the producer used, which this crate does not depend on.

Concurrent calls for the same (component_id, contract_name) coalesce onto one download-and-load: a second caller waits behind the first instead of racing a duplicate download or dlopen. A call for a different key is unaffected and proceeds immediately – the mutex guarding the loaded-component map is only ever held for a map lookup or insert, never across I/O.

Source

pub fn prefetch( &self, component_ids: &[&str], ) -> Result<Vec<CachedArtifact>, ComponentError>

Source

pub fn status( &self, component_id: &str, ) -> Result<ComponentStatus, ComponentError>

Report where component_id currently stands. Unlike Self::ensure_contract, Self::prefetch, and Self::cache_path, a Bundled entry is a legitimate answer here rather than a failure: it is this manager’s way of saying “linked in ahead of time, never downloaded or loaded through me”, not an error.

Source

pub fn cache_path(&self, component_id: &str) -> Result<PathBuf, ComponentError>

Source

pub fn cache_root(&self) -> &Path

Source

pub fn target(&self) -> &str

Trait Implementations§

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> 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> 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 = !

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.