pub trait Warp {
type Output: BankSafe;
type Group: Group;
// Required method
fn near(self, here: &mut Bank<Self::Group>) -> Self::Output;
// Provided method
fn drive<C>(self, outer: &mut Bank<C>) -> Self::Output
where C: Group,
Self: Sized { ... }
}bank only.Expand description
A deferred banked call: a function applied to its arguments, not yet run.
This is the Future of the banking world. A #[bank] function returns
impl Warp<Output = R>; drive is the .await that drives it,
performing the bank switch, running the function, and restoring the caller. The
concrete types are built by the macros and never named.
A #[bank::zero] function returns one too, and that one switches nothing: its
body is in bank 0 and always reachable, so it threads the caller’s token
straight through, and any banked call inside switches C to its target and back
to C. That is what makes a bank-0 helper safe to call from any bank, not
only from bank 0.
The #[must_use] sits on the trait rather than on the concrete types because a
banked function returns impl Warp, and that lint reads the trait.
Required Associated Types§
Required Methods§
Sourcefn near(self, here: &mut Bank<Self::Group>) -> Self::Output
fn near(self, here: &mut Bank<Self::Group>) -> Self::Output
Run the call in its own bank, given a token already there: the same-bank
“near call”. No switch happens, here proves the bank is mapped.
This is the primitive; drive is near wrapped in a
scope. Because it takes a Bank<Self::Group>, it pins the token’s
group: a run of near calls share one scope, and scope over them
infers the token’s group with no annotation. (For data, see
local.)
Provided Methods§
Sourcefn drive<C>(self, outer: &mut Bank<C>) -> Self::Output
fn drive<C>(self, outer: &mut Bank<C>) -> Self::Output
Run the call from any bank, leaving the caller’s bank C as it was: the
cross-bank counterpart of near. A banked call switches into its
bank and back (elided when C is already the target, or the target is
GroupZero); a bank-0 helper instead forwards C with no switch.
A resident caller inlines the switch, which lets the Warp collapse into a
plain call. A banked caller cannot: inlined switch code would unmap itself, so
it goes through a bank-0 trampoline instead.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".