Files
bitflags
bytes
buf
fmt
cfg_if
fnv
foreign_types
foreign_types_shared
futures
futures_channel
futures_core
futures_executor
futures_io
futures_macro
futures_sink
futures_task
futures_util
async_await
future
future
try_future
io
allow_std.rsbuf_reader.rsbuf_writer.rschain.rsclose.rscopy.rscopy_buf.rscursor.rsempty.rsfill_buf.rsflush.rsinto_sink.rslines.rsmod.rsread.rsread_exact.rsread_line.rsread_to_end.rsread_to_string.rsread_until.rsread_vectored.rsrepeat.rsseek.rssink.rssplit.rstake.rswindow.rswrite.rswrite_all.rswrite_vectored.rs
lock
sink
stream
futures_unordered
stream
buffer_unordered.rsbuffered.rscatch_unwind.rschain.rschunks.rscollect.rsconcat.rscycle.rsenumerate.rsfilter.rsfilter_map.rsflatten.rsfold.rsfor_each.rsfor_each_concurrent.rsforward.rsfuse.rsinto_future.rsmap.rsmod.rsnext.rspeek.rsready_chunks.rsscan.rsselect_next_some.rsskip.rsskip_while.rssplit.rstake.rstake_until.rstake_while.rsthen.rsunzip.rszip.rs
try_stream
task
getrandom
http
http_body
httparse
httpdate
hyper
body
client
common
proto
service
hyper_tls
itoa
lazy_static
libc
unix
log
memchr
mime
mime_guess
mio
event
net
sys
multipart
native_tls
num_cpus
num_traits
once_cell
openssl
openssl_probe
openssl_sys
ordered_float
pin_project
pin_project_internal
pin_project_lite
pin_utils
ppv_lite86
proc_macro2
proc_macro_hack
proc_macro_nested
quote
rand
distributions
weighted
rngs
seq
rand_chacha
rand_core
remove_dir_all
ryu
serde
de
private
ser
serde_derive
serde_json
serde_value
slab
socket2
syn
attr.rsawait.rsbigint.rsbuffer.rscustom_keyword.rscustom_punctuation.rsdata.rsderive.rsdiscouraged.rserror.rsexport.rsexpr.rsext.rsfile.rsgenerics.rsgroup.rsident.rsitem.rslib.rslifetime.rslit.rslookahead.rsmac.rsmacros.rsop.rsparse.rsparse_macro_input.rsparse_quote.rspat.rspath.rsprint.rspunctuated.rsreserved.rssealed.rsspan.rsspanned.rsstmt.rsthread.rstoken.rstt.rsty.rsverbatim.rswhitespace.rs
telegram_bot
telegram_bot_raw
requests
_base
answer_callback_query.rsanswer_inline_query.rsdelete_message.rsedit_message_caption.rsedit_message_live_location.rsedit_message_reply_markup.rsedit_message_text.rsexport_chat_invite_link.rsforward_message.rsget_chat.rsget_chat_administrators.rsget_chat_member.rsget_chat_members_count.rsget_file.rsget_me.rsget_updates.rsget_user_profile_photos.rskick_chat_member.rsleave_chat.rsmod.rspin_chat_message.rssend_audio.rssend_chat_action.rssend_contact.rssend_document.rssend_location.rssend_message.rssend_photo.rssend_poll.rssend_venue.rssend_video.rsstop_message_live_location.rsstop_poll.rsunban_chat_member.rsunpin_chat_message.rs
types
tempfile
tokio
fs
future
io
loom
std
macros
net
tcp
unix
park
runtime
blocking
task
thread_pool
sync
mpsc
rwlock
task
task
time
util
tokio_macros
tokio_native_tls
tower_service
tracing
tracing_attributes
tracing_core
tracing_futures
try_lock
unicase
unicode_xid
want
>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
//! Definition of the `PollFn` adapter combinator use super::assert_future; use core::fmt; use core::pin::Pin; use futures_core::future::Future; use futures_core::task::{Context, Poll}; /// Future for the [`poll_fn`] function. #[must_use = "futures do nothing unless you `.await` or poll them"] pub struct PollFn<F> { f: F, } impl<F> Unpin for PollFn<F> {} /// Creates a new future wrapping around a function returning [`Poll`]. /// /// Polling the returned future delegates to the wrapped function. /// /// # Examples /// /// ``` /// # futures::executor::block_on(async { /// use futures::future::poll_fn; /// use futures::task::{Context, Poll}; /// /// fn read_line(_cx: &mut Context<'_>) -> Poll<String> { /// Poll::Ready("Hello, World!".into()) /// } /// /// let read_future = poll_fn(read_line); /// assert_eq!(read_future.await, "Hello, World!".to_owned()); /// # }); /// ``` pub fn poll_fn<T, F>(f: F) -> PollFn<F> where F: FnMut(&mut Context<'_>) -> Poll<T> { assert_future::<T, _>(PollFn { f }) } impl<F> fmt::Debug for PollFn<F> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("PollFn").finish() } } impl<T, F> Future for PollFn<F> where F: FnMut(&mut Context<'_>) -> Poll<T>, { type Output = T; fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<T> { (&mut self.f)(cx) } }