Struct imap::extensions::idle::Handle
source · Expand description
Handle
allows a client to block waiting for changes to the remote mailbox.
The handle blocks using the IDLE
command
specificed in RFC 2177 until the underlying server state
changes in some way. While idling does inform the client what changes happened on the server,
this implementation will currently just block until anything changes, and then notify the
Note that the server MAY consider a client inactive if it has an IDLE command running, and if
such a server has an inactivity timeout it MAY log the client off implicitly at the end of its
timeout period. Because of that, clients using IDLE are advised to terminate the IDLE and
re-issue it at least every 29 minutes to avoid being logged off. Handle::wait_keepalive
does this. This still allows a client to receive immediate mailbox updates even though it need
only “poll” at half hour intervals.
As long as a Handle
is active, the mailbox cannot be otherwise accessed.
Implementations
sourceimpl<'a, T: SetReadTimeout + Read + Write + 'a> Handle<'a, T>
impl<'a, T: SetReadTimeout + Read + Write + 'a> Handle<'a, T>
sourcepub fn set_keepalive(&mut self, interval: Duration)
pub fn set_keepalive(&mut self, interval: Duration)
Set the keep-alive interval to use when wait_keepalive
is called.
The interval defaults to 29 minutes as dictated by RFC 2177.
sourcepub fn wait_keepalive(self) -> Result<()>
pub fn wait_keepalive(self) -> Result<()>
Block until the selected mailbox changes.
This method differs from Handle::wait
in that it will periodically refresh the IDLE
connection, to prevent the server from timing out our connection. The keepalive interval is
set to 29 minutes by default, as dictated by RFC 2177, but can be changed using
Handle::set_keepalive
.
This is the recommended method to use for waiting.
sourcepub fn wait_timeout(self, timeout: Duration) -> Result<()>
pub fn wait_timeout(self, timeout: Duration) -> Result<()>
Block until the selected mailbox changes, or until the given amount of time has expired.