Skip to main content

RuntimeReconfiguration

Struct RuntimeReconfiguration 

Source
pub struct RuntimeReconfiguration<'a> { /* private fields */ }
Expand description

Non-escapable reconfiguration edit view.

Implementations§

Source§

impl RuntimeReconfiguration<'_>

Source

pub fn execution_policy(&mut self, policy: ExecutionPolicy) -> &mut Self

Replace the candidate execution policy.

Source

pub fn register_engine( &mut self, value: EngineRegistration, ) -> Result<&mut Self, RuntimeConfigError>

Register a new engine in this reconfiguration.

§Errors

Returns RuntimeConfigError::DuplicateEngine if a different candidate with the same engine ID is already present.

Source

pub fn replace_engine( &mut self, value: EngineRegistration, ) -> Result<&mut Self, RuntimeConfigError>

Replace an existing engine in this reconfiguration.

§Errors

Returns RuntimeConfigError::MissingEngine if the engine ID is absent.

Source

pub fn remove_engine( &mut self, id: &EngineId, ) -> Result<&mut Self, RuntimeConfigError>

Remove an existing engine in this reconfiguration.

§Errors

Returns RuntimeConfigError::MissingEngine if the engine ID is absent.

Source

pub fn install_extension_module( &mut self, value: Arc<dyn ExtensionModule>, ) -> Result<&mut Self, RuntimeConfigError>

Install an extension module in this reconfiguration.

§Errors

Returns RuntimeConfigError::ExtensionModule when module configuration fails or a distinct module already uses the same module ID.

Source

pub fn register_transfer_provider( &mut self, source: TransferEndpoint, destination: TransferEndpoint, provider: Arc<dyn TransferProvider>, ) -> Result<&mut Self, RuntimeConfigError>

Register a transfer provider in this reconfiguration by endpoint pair.

§Examples
use std::sync::Arc;
use tenferro_runtime::{
    assemble_preparation_only_engine_registration, CoreCapabilityBundle, EngineId,
    EngineRegistration, EngineRegistrationMetadata, Error, ExecutionContextIdentity,
    HardwareClassId, PreparationOnlyEngineRegistrationConfig, ProviderDeviceIdentity,
    ProviderId, Runtime, StorageClass, TransferEndpoint, TransferProvider, TransferRequest,
};

#[derive(Debug)]
struct ExampleProvider;

impl TransferProvider for ExampleProvider {
    fn transfer_blocking(
        &self,
        _request: TransferRequest<'_>,
    ) -> tenferro_runtime::Result<tenferro_tensor::Tensor> {
        Err(Error::Internal("the example does not execute a transfer".into()))
    }
}

fn registration(
    id: &str,
    storage: &StorageClass,
) -> Result<EngineRegistration, tenferro_runtime::RuntimeConfigError> {
    let metadata = EngineRegistrationMetadata::new(
        EngineId::new(id)?,
        ProviderDeviceIdentity::new(
            ProviderId::new("example.provider")?,
            format!("engine:{id}"),
        )?,
        HardwareClassId::new("example.hardware")?,
        Arc::from([storage.clone()]),
        storage.clone(),
        CoreCapabilityBundle::default(),
    );
    Ok(assemble_preparation_only_engine_registration(
        PreparationOnlyEngineRegistrationConfig::new(
            metadata,
            ExecutionContextIdentity::of::<()>(),
        ),
    )?)
}

let storage = StorageClass::new("example.storage.host")?;
let source_id = EngineId::new("example.engine.source")?;
let destination_id = EngineId::new("example.engine.destination")?;
let mut builder = Runtime::builder();
builder.register_engine(registration(source_id.as_str(), &storage)?)?;
builder.register_engine(registration(destination_id.as_str(), &storage)?)?;
let runtime = builder.build()?;
runtime.reconfigure(|edit| {
    edit.register_transfer_provider(
        TransferEndpoint::new(source_id, storage.clone()),
        TransferEndpoint::new(destination_id, storage),
        Arc::new(ExampleProvider),
    )?;
    Ok(())
})?;
assert_eq!(runtime.snapshot()?.transfer_provider_count(), 1);
§Errors

Returns RuntimeConfigError::ConflictingRegistration if a different provider is already registered for the same endpoint pair. The complete endpoint pair is validated before this reconfiguration is published.

Source

pub fn remove_transfer_provider( &mut self, source: TransferEndpoint, destination: TransferEndpoint, ) -> Result<&mut Self, RuntimeConfigError>

Remove the transfer provider for an endpoint pair in this reconfiguration.

§Errors

Returns RuntimeConfigError::MissingTransferProvider when the exact endpoint pair is not registered.

Source

pub fn replace_extension_module( &mut self, value: Arc<dyn ExtensionModule>, ) -> Result<&mut Self, RuntimeConfigError>

Replace an extension module in this reconfiguration, installing when absent.

§Errors

Returns RuntimeConfigError::ExtensionModule when module configuration fails.

Source

pub fn remove_extension_module( &mut self, id: &ExtensionModuleId, ) -> Result<&mut Self, RuntimeConfigError>

Remove an extension module if present.

§Errors

This method currently has no failing absent-module path; it returns RuntimeConfigError only for future validated module removal failures.

Trait Implementations§

Source§

impl Debug for RuntimeReconfiguration<'_>

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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<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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.
§

impl<T> MaybeSend for T
where T: Send,

§

impl<T> MaybeSendSync for T
where T: Send + Sync,

§

impl<T> MaybeSync for T
where T: Sync,