pub struct RustAdapter { /* private fields */ }Expand description
Adapter that routes component operations to native Rust implementations.
This adapter does NOT spawn any shell subprocess. All work is done within the Rust process, producing output that matches the format of legacy shell scripts.
§Example
ⓘ
use rusty_stack::adapter::rust_adapter::RustAdapter;
use rusty_stack::adapter::AdapterRegistry;
let adapter = RustAdapter::new(Box::new(|id, version| {
Ok((format!("{id}: {version} installed"), String::new()))
}));
let mut registry = AdapterRegistry::new();
registry.register_rust("pytorch", Box::new(adapter));Implementations§
Source§impl RustAdapter
impl RustAdapter
Sourcepub fn new(executor: RustAdapterFn) -> Self
pub fn new(executor: RustAdapterFn) -> Self
Create a new Rust adapter with the given executor function.
Sourcepub fn simple_success(message_prefix: &str) -> Self
pub fn simple_success(message_prefix: &str) -> Self
Create a simple Rust adapter that always succeeds with a fixed message.
Sourcepub fn always_fails(exit_code: i32, message: &str) -> Self
pub fn always_fails(exit_code: i32, message: &str) -> Self
Create a Rust adapter that always fails with a fixed exit code.
Trait Implementations§
Source§impl Adapter for RustAdapter
impl Adapter for RustAdapter
Source§fn execute(
&self,
component_id: &str,
version: &str,
) -> Result<AdapterOutput, AdapterError>
fn execute( &self, component_id: &str, version: &str, ) -> Result<AdapterOutput, AdapterError>
Execute the adapter for the given component. Read more
Source§fn executor_kind(&self) -> ExecutorKind
fn executor_kind(&self) -> ExecutorKind
The kind of executor this adapter uses.
Auto Trait Implementations§
impl !RefUnwindSafe for RustAdapter
impl !UnwindSafe for RustAdapter
impl Freeze for RustAdapter
impl Send for RustAdapter
impl Sync for RustAdapter
impl Unpin for RustAdapter
impl UnsafeUnpin for RustAdapter
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
Mutably borrows from an owned value. Read more
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> ⓘ
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 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> ⓘ
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