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§
Sourcetype ConstructedFrom
type ConstructedFrom
The type that this Account
can be constructed from.
The progenitor [Account
], or, for a standalone account type,
Arc<MemoryQuotaTracker>
.
Required Methods§
Sourcefn new(progenitor: &Self::ConstructedFrom) -> Result<Self, Error>
fn new(progenitor: &Self::ConstructedFrom) -> Result<Self, Error>
Create a new Account at this layer, given the progenitor
Sourcefn as_raw_account(&self) -> &Account
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
]
Sourcefn from_raw_account(account: Account) -> Self
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).
Sourcefn into_raw_account(self) -> Account
fn into_raw_account(self) -> Account
Unwrap this into a raw [Account
]
Provided Methods§
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.