Trait SpecificAccount

Source
pub trait SpecificAccount: Sized {
    type ConstructedFrom;

    // Required methods
    fn new(progenitor: &Self::ConstructedFrom) -> Result<Self, Error>;
    fn as_raw_account(&self) -> &Account;
    fn from_raw_account(account: Account) -> Self;
    fn into_raw_account(self) -> Account;

    // Provided method
    fn new_noop() -> Self { ... }
}
Expand description

An [Account], whose type indicates which layer of the stack it’s for

Required Associated Types§

Source

type ConstructedFrom

The type that this Account can be constructed from.

The progenitor [Account], or, for a standalone account type, Arc<MemoryQuotaTracker>.

Required Methods§

Source

fn new(progenitor: &Self::ConstructedFrom) -> Result<Self, Error>

Create a new Account at this layer, given the progenitor

Source

fn as_raw_account(&self) -> &Account

Access the underlying raw [Account]

Use this when you need to actually track memory, for example when constructing a queue with [tor_memquota::mq_queue]

Source

fn from_raw_account(account: Account) -> Self

Wrap an Account, blessing it with a layer

Generally, don’t call this function. Instead, use new()(SpecificAccount::new).

Source

fn into_raw_account(self) -> Account

Unwrap this into a raw [Account]

Provided Methods§

Source

fn new_noop() -> Self

Create a new dummy account for testing purposes

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§