pub trait ErasedMemory: Send + Sync {
// Required methods
fn add_message_erased<'a>(
&'a self,
message: &'a Message,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'a>>;
fn get_messages_erased<'a>(
&'a self,
) -> Pin<Box<dyn Future<Output = Result<Vec<Message>>> + Send + 'a>>;
fn clear_erased<'a>(
&'a self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'a>>;
// Provided method
fn with_messages_erased<'a>(
&'a self,
f: Box<dyn FnOnce(&[Message]) + Send + 'a>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'a>> { ... }
}Expand description
Object-safe wrapper for the Memory trait, enabling dynamic dispatch via Arc<dyn ErasedMemory>.
Required Methods§
fn add_message_erased<'a>( &'a self, message: &'a Message, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'a>>
fn get_messages_erased<'a>( &'a self, ) -> Pin<Box<dyn Future<Output = Result<Vec<Message>>> + Send + 'a>>
fn clear_erased<'a>( &'a self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'a>>
Provided Methods§
Sourcefn with_messages_erased<'a>(
&'a self,
f: Box<dyn FnOnce(&[Message]) + Send + 'a>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'a>>
fn with_messages_erased<'a>( &'a self, f: Box<dyn FnOnce(&[Message]) + Send + 'a>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'a>>
Object-safe counterpart of Memory::with_messages. Callers return
values by writing into locals captured by f.
Default-implemented (via ErasedMemory::get_messages_erased, one
full clone) so direct ErasedMemory implementors written before this
method existed keep compiling. The blanket impl for T: Memory
overrides it to route through Memory::with_messages, so backends
that override that get their no-clone path through SharedMemory
too.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".