pub struct AskGate { /* private fields */ }Expand description
An asynchronous gate answered by ticket. Deny by default: until
AskGate::attach every question is refused at once
(NO_GATE_REGISTERED). Once attached, each question the engine asks
queues a GateRequest (AskGate::take_requests) and runs the
notifier (AskGate::set_notify); AskGate::answer delivers the
verdict. An answer is remembered and reused for the same question from
any connection on this gate (NetGate::decide).
A request the engine stops waiting for (its connection closed, or
NetGate::ask_timeout passed, which is a refusal) leaves the queue
and its ticket: a later answer for it returns false. Dropping the
last clone, or AskGate::detach, refuses everything pending.
Single-threaded, like the engine: answer on the engine’s thread.
Implementations§
Source§impl AskGate
impl AskGate
Sourcepub fn detach(&self)
pub fn detach(&self)
Stops asking: everything pending is refused, and so is every later question that wasn’t answered before.
pub fn is_attached(&self) -> bool
Sourcepub fn set_notify(&self, f: impl Fn() + 'static)
pub fn set_notify(&self, f: impl Fn() + 'static)
Runs after each request is queued (a front end wakes its event loop here). It must not call back into the engine.
Sourcepub fn set_timeout(&self, timeout: Duration)
pub fn set_timeout(&self, timeout: Duration)
How long the engine waits for an answer (default
DEFAULT_ASK_TIMEOUT).
Sourcepub fn take_requests(&self) -> Vec<GateRequest>
pub fn take_requests(&self) -> Vec<GateRequest>
The requests queued since the last call, oldest first.
Trait Implementations§
Source§impl NetGate for AskGate
impl NetGate for AskGate
Source§fn decide(&self, reach: &Reach) -> Option<Verdict>
fn decide(&self, reach: &Reach) -> Option<Verdict>
Some; None makes the engine
ask. Called again each time the engine needs the
question answered, so it may answer from a cache of its own.Source§fn ask(&self, reach: Reach) -> LocalBoxFuture<'static, Verdict>
fn ask(&self, reach: Reach) -> LocalBoxFuture<'static, Verdict>
decide returned None, at most once per question at a time
per connection (the engine dedupes and remembers the answer). The
future is dropped when the connection closes or
NetGate::ask_timeout passes (a refusal). The default answers from
NetGate::decide (None is a refusal).Source§fn interfaces(&self) -> Option<Verdict>
fn interfaces(&self) -> Option<Verdict>
--allow-sys=networkInterfaces.)Source§fn ask_interfaces(&self) -> LocalBoxFuture<'static, Verdict>
fn ask_interfaces(&self) -> LocalBoxFuture<'static, Verdict>
Source§fn ask_timeout(&self) -> Duration
fn ask_timeout(&self) -> Duration
ask /
ask_interfaces answer before it takes
the question as refused.Auto Trait Implementations§
impl !RefUnwindSafe for AskGate
impl !Send for AskGate
impl !Sync for AskGate
impl !UnwindSafe for AskGate
impl Forget for AskGate
impl Freeze for AskGate
impl Move for AskGate
impl Unpin for AskGate
impl UnsafeUnpin for AskGate
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.