OwnedSomeStaticExecutorErasingNotifier

Struct OwnedSomeStaticExecutorErasingNotifier 

Source
pub struct OwnedSomeStaticExecutorErasingNotifier<UnderlyingExecutor> { /* private fields */ }
Expand description

An adapter that wraps a static executor and erases its notifier type.

OwnedSomeStaticExecutorErasingNotifier takes ownership of an underlying static executor and implements SomeStaticExecutor with a type-erased notifier (Box<dyn ExecutorNotified>). This allows different executor types to be used interchangeably through the DynStaticExecutor type.

§Type Parameters

  • UnderlyingExecutor - The concrete static executor type being wrapped

§When to Use

Use this adapter when you need to:

  • Store executors with different notifier types in the same collection
  • Pass executors through a uniform interface that accepts DynStaticExecutor
  • Erase the executor’s notifier type while maintaining ownership

§Examples

§Creating and using an erased executor

use some_executor::static_support::OwnedSomeStaticExecutorErasingNotifier;
use some_executor::{SomeStaticExecutor, DynStaticExecutor};
use some_executor::task::{Task, Configuration};

// With a concrete executor implementation:
// let executor = MyExecutor::new();
// let mut erased = OwnedSomeStaticExecutorErasingNotifier::new(executor);
//
// // Spawn tasks as usual
// let task = Task::without_notifications(
//     "example".to_string(),
//     Configuration::default(),
//     async { 42 }
// );
// let observer = erased.spawn_static(task);

§Converting to a boxed dynamic executor

use some_executor::static_support::OwnedSomeStaticExecutorErasingNotifier;
use some_executor::{SomeStaticExecutor, DynStaticExecutor};

// With a concrete executor:
// let executor = MyExecutor::new();
// let erased = OwnedSomeStaticExecutorErasingNotifier::new(executor);
//
// // Get a boxed version for storage or passing around
// let boxed: Box<DynStaticExecutor> = erased.clone_box();

§Implementation Notes

The adapter delegates all executor methods to the underlying executor, with the exception of executor_notifier() which wraps the underlying notifier in a Box<dyn ExecutorNotified>.

Implementations§

Source§

impl<UnderlyingExecutor> OwnedSomeStaticExecutorErasingNotifier<UnderlyingExecutor>

Source

pub fn new(executor: UnderlyingExecutor) -> Self

Creates a new adapter wrapping the provided executor.

§Arguments
  • executor - The static executor to wrap
§Examples
use some_executor::static_support::OwnedSomeStaticExecutorErasingNotifier;

// With a concrete executor:
// let executor = MyExecutor::new();
// let erased = OwnedSomeStaticExecutorErasingNotifier::new(executor);

Trait Implementations§

Source§

impl<UnderlyingExecutor: Debug> Debug for OwnedSomeStaticExecutorErasingNotifier<UnderlyingExecutor>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<UnderlyingExecutor: SomeStaticExecutor> SomeStaticExecutor for OwnedSomeStaticExecutorErasingNotifier<UnderlyingExecutor>

Source§

type ExecutorNotifier = Box<dyn ExecutorNotified>

Source§

fn spawn_static<F, Notifier: ObserverNotified<F::Output>>( &mut self, task: Task<F, Notifier>, ) -> impl Observer<Value = F::Output>
where Self: Sized, F: Future + 'static, F::Output: 'static + Unpin,

Spawns a static, non-Send future onto the runtime. Read more
Source§

fn spawn_static_async<F, Notifier: ObserverNotified<F::Output>>( &mut self, task: Task<F, Notifier>, ) -> impl Future<Output = impl Observer<Value = F::Output>>
where Self: Sized, F: Future + 'static, F::Output: 'static + Unpin,

Spawns a static, non-Send future onto the runtime. Read more
Source§

fn spawn_static_objsafe( &mut self, task: ObjSafeStaticTask, ) -> BoxedStaticObserver

Spawns a static, non-Send future onto the runtime. Read more
Source§

fn spawn_static_objsafe_async<'s>( &'s mut self, task: ObjSafeStaticTask, ) -> BoxedStaticObserverFuture<'s>

Spawns a static, non-Send future onto the runtime. Read more
Source§

fn clone_box(&self) -> Box<DynStaticExecutor>

Clones the executor. Read more
Source§

fn executor_notifier(&mut self) -> Option<Self::ExecutorNotifier>

Produces an executor notifier.

Auto Trait Implementations§

§

impl<UnderlyingExecutor> Freeze for OwnedSomeStaticExecutorErasingNotifier<UnderlyingExecutor>
where UnderlyingExecutor: Freeze,

§

impl<UnderlyingExecutor> RefUnwindSafe for OwnedSomeStaticExecutorErasingNotifier<UnderlyingExecutor>
where UnderlyingExecutor: RefUnwindSafe,

§

impl<UnderlyingExecutor> Send for OwnedSomeStaticExecutorErasingNotifier<UnderlyingExecutor>
where UnderlyingExecutor: Send,

§

impl<UnderlyingExecutor> Sync for OwnedSomeStaticExecutorErasingNotifier<UnderlyingExecutor>
where UnderlyingExecutor: Sync,

§

impl<UnderlyingExecutor> Unpin for OwnedSomeStaticExecutorErasingNotifier<UnderlyingExecutor>
where UnderlyingExecutor: Unpin,

§

impl<UnderlyingExecutor> UnwindSafe for OwnedSomeStaticExecutorErasingNotifier<UnderlyingExecutor>
where UnderlyingExecutor: UnwindSafe,

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, 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.