Struct Registry
struct Registry { ... }
Registers I/O resources.
Implementations
impl Registry
fn register<S>(self: &Self, source: &mut S, token: Token, interests: Interest) -> Result<()> where S: Source + ?SizedRegister an
event::Sourcewith thePollinstance.Once registered, the
Pollinstance will monitor the event source for readiness state changes. When it notices a state change, it will return a readiness event for the handle the next timepollis called.See
Polldocs for a high level overview.Arguments
source: &mut S: event::Source: This is the source of events that thePollinstance should monitor for readiness state changes.token: Token: The caller picks a token to associate with the socket. Whenpollreturns an event for the handle, this token is included. This allows the caller to map the event to its source. The token associated with theevent::Sourcecan be changed at any time by callingreregister.See documentation on
Tokenfor an example showing how to pickTokenvalues.interest: Interest: Specifies which operationsPollshould monitor for readiness.Pollwill only return readiness events for operations specified by this argument.If a socket is registered with readable interest and the socket becomes writable, no event will be returned from
poll.The readiness interest for an
event::Sourcecan be changed at any time by callingreregister.Notes
Callers must ensure that if a source being registered with a
Pollinstance was previously registered with thatPollinstance, then a call toderegisterhas already occurred. Consecutive calls toregisteris unspecified behavior.Unless otherwise specified, the caller should assume that once an event source is registered with a
Pollinstance, it is bound to thatPollinstance for the lifetime of the event source. This remains true even if the event source is deregistered from the poll instance usingderegister.Examples
# use Error; # use net; #fn reregister<S>(self: &Self, source: &mut S, token: Token, interests: Interest) -> Result<()> where S: Source + ?SizedRe-register an
event::Sourcewith thePollinstance.Re-registering an event source allows changing the details of the registration. Specifically, it allows updating the associated
tokenandinterestsspecified in previousregisterandreregistercalls.The
reregisterarguments fully override the previous values. In other words, if a socket is registered withreadableinterest and the call toreregisterspecifieswritable, then read interest is no longer requested for the handle.The event source must have previously been registered with this instance of
Poll, otherwise the behavior is unspecified.See the
registerdocumentation for details about the function arguments and see thestructdocs for a high level overview of polling.Examples
# use Error; # use net; #fn deregister<S>(self: &Self, source: &mut S) -> Result<()> where S: Source + ?SizedDeregister an
event::Sourcewith thePollinstance.When an event source is deregistered, the
Pollinstance will no longer monitor it for readiness state changes. Deregistering clears up any internal resources needed to track the handle. After an explicit call to this method completes, it is guaranteed that the token previously registered to this handle will not be returned by a future poll, so long as a happens-before relationship is established between this call and the poll.The event source must have previously been registered with this instance of
Poll, otherwise the behavior is unspecified.A handle can be passed back to
registerafter it has been deregistered; however, it must be passed back to the samePollinstance, otherwise the behavior is unspecified.Examples
# use Error; # use net; #fn try_clone(self: &Self) -> Result<Registry>Creates a new independently owned
Registry.Event sources registered with this
Registrywill be registered with the originalRegistryandPollinstance.
impl AsRawFd for Registry
fn as_raw_fd(self: &Self) -> RawFd
impl Debug for Registry
fn fmt(self: &Self, fmt: &mut Formatter<'_>) -> Result
impl Freeze for Registry
impl RefUnwindSafe for Registry
impl Send for Registry
impl Sync for Registry
impl Unpin for Registry
impl UnsafeUnpin for Registry
impl UnwindSafe for Registry
impl<T> Any for Registry
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for Registry
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for Registry
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> From for Registry
fn from(t: T) -> TReturns the argument unchanged.
impl<T, U> Into for Registry
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for Registry
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for Registry
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>