Skip to main content

Extension

Trait Extension 

Source
pub trait Extension: Send + 'static {
    // Required methods
    fn as_mut_any(&mut self) -> &mut dyn Any;
    fn type_id(&self) -> TypeId;

    // Provided methods
    fn start_transaction(&mut self, ty: TransactionType) { ... }
    fn commit_transaction(&mut self, ty: TransactionType) { ... }
    fn rollback_transaction(&mut self, ty: TransactionType) { ... }
}
Expand description

Marker trait for types that should be registered as Externalities extension.

As extensions are stored as Box<Any>, this trait should give more confidence that the correct type is registered and requested.

Required Methods§

Source

fn as_mut_any(&mut self) -> &mut dyn Any

Return the extension as &mut dyn Any.

This is a trick to make the trait type castable into an Any.

Source

fn type_id(&self) -> TypeId

Get the TypeId of this Extension.

Provided Methods§

Source

fn start_transaction(&mut self, ty: TransactionType)

Start a transaction of type ty.

Source

fn commit_transaction(&mut self, ty: TransactionType)

Commit a transaction of type ty.

Source

fn rollback_transaction(&mut self, ty: TransactionType)

Rollback a transaction of type ty.

Trait Implementations§

Source§

impl Extension for Box<dyn Extension>

Source§

fn as_mut_any(&mut self) -> &mut dyn Any

Return the extension as &mut dyn Any. Read more
Source§

fn type_id(&self) -> TypeId

Get the TypeId of this Extension.
Source§

fn start_transaction(&mut self, ty: TransactionType)

Start a transaction of type ty.
Source§

fn commit_transaction(&mut self, ty: TransactionType)

Commit a transaction of type ty.
Source§

fn rollback_transaction(&mut self, ty: TransactionType)

Rollback a transaction of type ty.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Extension for Box<dyn Extension>

Implementors§