| 1 |
//! Adapters for async IO objects |
| 2 |
//! |
| 3 |
//! This module mainly hosts the [`Async`] adapter for making IO objects async with readiness |
| 4 |
//! monitoring backed by an [`EventLoop`](crate::EventLoop). See [`LoopHandle::adapt_io`] for |
| 5 |
//! how to create them. |
| 6 |
//! |
| 7 |
//! [`LoopHandle::adapt_io`]: crate::LoopHandle#method.adapt_io |
| 8 |
|
| 9 |
use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::cellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/::RefCellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/RefCell#; |
| 10 |
use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::osrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/::unixrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/unix/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/unix/io/::{AsRawFdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/fd/raw/AsRawFd#, RawFdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/fd/raw/RawFd#}; |
| •11 |
use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::osrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/::fdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/fd/::BorrowedFdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/fd/owned/BorrowedFd#; |
| 12 |
use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::pinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/::Pinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/Pin#; |
| 13 |
use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::rcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/::Rcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/Rc#; |
| 14 |
use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::taskrust-analyzer cargo std https://github.com/rust-lang/rust/library/std task/::{Contextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/wake/Context#, Pollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll# as TaskPollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#, Wakerrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/wake/Waker#}; |
| 15 |
|
| 16 |
use nixrust-analyzer cargo nix 0.30.1 crate/::fcntlrust-analyzer cargo nix 0.30.1 fcntl/::{fcntlrust-analyzer cargo nix 0.30.1 fcntl/fcntl()., FcntlArgrust-analyzer cargo nix 0.30.1 fcntl/FcntlArg#, OFlagrust-analyzer cargo nix 0.30.1 fcntl/OFlag#}; |
| 17 |
|
| 18 |
#[cfg(feature = "futures-io")] |
| 19 |
use futures_iorust-analyzer cargo futures-io 0.3.25 crate/::{AsyncReadrust-analyzer cargo futures-io 0.3.25 if_std/AsyncRead#, AsyncWriterust-analyzer cargo futures-io 0.3.25 if_std/AsyncWrite#, IoSlicerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/IoSlice#, IoSliceMutrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/IoSliceMut#}; |
| 20 |
|
| 21 |
use craterust-analyzer cargo calloop 0.10.5 crate/::{ |
| 22 |
loop_logicrust-analyzer cargo calloop 0.10.5 loop_logic/::LoopInnerrust-analyzer cargo calloop 0.10.5 loop_logic/LoopInner#, sourcesrust-analyzer cargo calloop 0.10.5 sources/::EventDispatcherrust-analyzer cargo calloop 0.10.5 sources/EventDispatcher#, Interestrust-analyzer cargo calloop 0.10.5 sys/Interest#, Moderust-analyzer cargo calloop 0.10.5 sys/Mode#, Pollrust-analyzer cargo calloop 0.10.5 sys/Poll#, PostActionrust-analyzer cargo calloop 0.10.5 sources/PostAction#, Readinessrust-analyzer cargo calloop 0.10.5 sys/Readiness#, |
| 23 |
Tokenrust-analyzer cargo calloop 0.10.5 sys/Token#, TokenFactoryrust-analyzer cargo calloop 0.10.5 sys/TokenFactory#, |
| 24 |
}; |
| 25 |
|
| 26 |
/// Adapter for async IO manipulations |
| 27 |
/// |
| 28 |
/// This type wraps an IO object, providing methods to create futures waiting for its |
| 29 |
/// readiness. |
| 30 |
/// |
| 31 |
/// If the `futures-io` cargo feature is enabled, it also implements `AsyncRead` and/or |
| 32 |
/// `AsyncWrite` if the underlying type implements `Read` and/or `Write`. |
| 33 |
/// |
| 34 |
/// Note that this adapter and the futures procuded from it and *not* threadsafe. |
| 35 |
pub struct Asyncrust-analyzer cargo calloop 0.10.5 io/Async#<'l, F: AsRawFdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/fd/raw/AsRawFd#> { |
| 36 |
fdrust-analyzer cargo calloop 0.10.5 io/Async#fd.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<F>, |
| 37 |
dispatcherrust-analyzer cargo calloop 0.10.5 io/Async#dispatcher.: Rcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/Rc#<RefCellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/RefCell#<IoDispatcherrust-analyzer cargo calloop 0.10.5 io/IoDispatcher#>>, |
| 38 |
innerrust-analyzer cargo calloop 0.10.5 io/Async#inner.: Rcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/Rc#<dyn IoLoopInnerrust-analyzer cargo calloop 0.10.5 io/IoLoopInner# + 'l>, |
| 39 |
old_flagsrust-analyzer cargo calloop 0.10.5 io/Async#old_flags.: OFlagrust-analyzer cargo nix 0.30.1 fcntl/OFlag#, |
| 40 |
} |
| 41 |
|
| 42 |
impl<'l, F: AsRawFdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/fd/raw/AsRawFd# + stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug#> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# for Asyncrust-analyzer cargo calloop 0.10.5 io/Async#<'l, F> { |
| 43 |
#[cfg_attr(coverage, no_coverage)] |
| 44 |
fn fmtrust-analyzer cargo calloop 0.10.5 io/impl#[`Async<'l, F>`][Debug]fmt().(&self, f: &mut stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# { |
| 45 |
f.debug_structrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]debug_struct().("Async").fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("fd", &self.fdrust-analyzer cargo calloop 0.10.5 io/Async#fd.).finishrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]finish().() |
| 46 |
} |
| 47 |
} |
| 48 |
|
| 49 |
impl<'l, F: AsRawFdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/fd/raw/AsRawFd#> Asyncrust-analyzer cargo calloop 0.10.5 io/Async#<'l, F> { |
| 50 |
pub(craterust-analyzer cargo calloop 0.10.5 crate/) fn newrust-analyzer cargo calloop 0.10.5 io/impl#[`Async<'l, F>`]new().<Data>(inner: Rcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/Rc#<LoopInnerrust-analyzer cargo calloop 0.10.5 loop_logic/LoopInner#<'l, Data>>, fd: F) -> craterust-analyzer cargo calloop 0.10.5 crate/::Resultrust-analyzer cargo calloop 0.10.5 error/Result#<Asyncrust-analyzer cargo calloop 0.10.5 io/Async#<'l, F>> { |
| 51 |
let rawfd = fd.as_raw_fdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/fd/raw/AsRawFd#as_raw_fd().(); |
| 52 |
// set non-blocking |
| •53 |
let old_flags = fcntlrust-analyzer cargo nix 0.30.1 fcntl/fcntl().(unsafe { BorrowedFdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/fd/owned/BorrowedFd#::borrow_rawrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/fd/owned/impl#[`BorrowedFd<'_>`]borrow_raw().(rawfd) }, FcntlArgrust-analyzer cargo nix 0.30.1 fcntl/FcntlArg#::F_GETFLrust-analyzer cargo nix 0.30.1 fcntl/FcntlArg#F_GETFL#)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| •54 |
let old_flags = unsafe { OFlagrust-analyzer cargo nix 0.30.1 fcntl/OFlag#::from_bits_retainrust-analyzer cargo nix 0.30.1 fcntl/impl#[OFlag]from_bits_retain().(old_flags) }; |
| •55 |
fcntlrust-analyzer cargo nix 0.30.1 fcntl/fcntl().(unsafe { BorrowedFdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/fd/owned/BorrowedFd#::borrow_rawrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/fd/owned/impl#[`BorrowedFd<'_>`]borrow_raw().(rawfd) }, FcntlArgrust-analyzer cargo nix 0.30.1 fcntl/FcntlArg#::F_SETFLrust-analyzer cargo nix 0.30.1 fcntl/FcntlArg#F_SETFL#(old_flags rust-analyzer cargo nix 0.30.1 fcntl/impl#[OFlag][`BitOr<Self>`]bitor().|rust-analyzer cargo nix 0.30.1 fcntl/impl#[OFlag][`BitOr<Self>`]bitor(). rust-analyzer cargo nix 0.30.1 fcntl/impl#[OFlag][`BitOr<Self>`]bitor().OFlagrust-analyzer cargo nix 0.30.1 fcntl/OFlag#::O_NONBLOCKrust-analyzer cargo nix 0.30.1 fcntl/impl#[OFlag]O_NONBLOCK.))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 56 |
// register in the loop |
| 57 |
let dispatcher = Rcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/Rc#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/impl#[`Rc<T>`]new().(RefCellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/RefCell#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]new().(IoDispatcherrust-analyzer cargo calloop 0.10.5 io/IoDispatcher# { |
| 58 |
fdrust-analyzer cargo calloop 0.10.5 io/IoDispatcher#fd.: rawfd, |
| 59 |
tokenrust-analyzer cargo calloop 0.10.5 io/IoDispatcher#token.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 60 |
wakerrust-analyzer cargo calloop 0.10.5 io/IoDispatcher#waker.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 61 |
is_registeredrust-analyzer cargo calloop 0.10.5 io/IoDispatcher#is_registered.: false, |
| 62 |
interestrust-analyzer cargo calloop 0.10.5 io/IoDispatcher#interest.: Interestrust-analyzer cargo calloop 0.10.5 sys/Interest#::EMPTYrust-analyzer cargo calloop 0.10.5 sys/impl#[Interest]EMPTY., |
| 63 |
last_readinessrust-analyzer cargo calloop 0.10.5 io/IoDispatcher#last_readiness.: Readinessrust-analyzer cargo calloop 0.10.5 sys/Readiness#::EMPTYrust-analyzer cargo calloop 0.10.5 sys/impl#[Readiness]EMPTY., |
| 64 |
})); |
| 65 |
let key = inner.sourcesrust-analyzer cargo calloop 0.10.5 loop_logic/LoopInner#sources..borrow_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]borrow_mut().().insertrust-analyzer cargo slotmap 1.0.6 basic/impl#[`SlotMap<K, V>`]insert().(dispatcher.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/impl#[`Rc<T, A>`][Clone]clone().()); |
| 66 |
dispatcher.borrow_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]borrow_mut().().tokenrust-analyzer cargo calloop 0.10.5 io/IoDispatcher#token. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Tokenrust-analyzer cargo calloop 0.10.5 sys/Token# { keyrust-analyzer cargo calloop 0.10.5 sys/Token#key., sub_idrust-analyzer cargo calloop 0.10.5 sys/Token#sub_id.: 0 }); |
| 67 |
inner.registerrust-analyzer cargo calloop 0.10.5 io/impl#[`LoopInner<'l, Data>`][IoLoopInner]register().(&dispatcher)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 68 |
|
| 69 |
// Straightforward casting would require us to add the bound `Data: 'l` but we don't actually need it |
| 70 |
// as this module never accesses the dispatch data, so we use transmute to erase it |
| 71 |
let inner: Rcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/Rc#<dyn IoLoopInnerrust-analyzer cargo calloop 0.10.5 io/IoLoopInner# + 'l> = |
| 72 |
unsafe { stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::transmuterust-analyzer cargo core https://github.com/rust-lang/rust/library/core intrinsics/transmute().(inner as Rcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/Rc#<dyn IoLoopInnerrust-analyzer cargo calloop 0.10.5 io/IoLoopInner#>) }; |
| 73 |
|
| 74 |
Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Asyncrust-analyzer cargo calloop 0.10.5 io/Async# { |
| 75 |
fdrust-analyzer cargo calloop 0.10.5 io/Async#fd.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(fd), |
| 76 |
dispatcherrust-analyzer cargo calloop 0.10.5 io/Async#dispatcher., |
| 77 |
innerrust-analyzer cargo calloop 0.10.5 io/Async#inner., |
| 78 |
old_flagsrust-analyzer cargo calloop 0.10.5 io/Async#old_flags., |
| 79 |
}) |
| 80 |
} |
| 81 |
|
| 82 |
/// Mutably access the underlying IO object |
| 83 |
pub fn get_mutrust-analyzer cargo calloop 0.10.5 io/impl#[`Async<'l, F>`]get_mut().(&mut self) -> &mut F { |
| 84 |
self.fdrust-analyzer cargo calloop 0.10.5 io/Async#fd..as_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_mut().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().() |
| 85 |
} |
| 86 |
|
| 87 |
/// A future that resolves once the object becomes ready for reading |
| 88 |
pub fn readablerust-analyzer cargo calloop 0.10.5 io/impl#[`Async<'l, F>`]readable().<'s>(&'s mut self) -> Readablerust-analyzer cargo calloop 0.10.5 io/Readable#<'s, 'l, F> { |
| 89 |
Readablerust-analyzer cargo calloop 0.10.5 io/Readable# { iorust-analyzer cargo calloop 0.10.5 io/Readable#io.: self } |
| 90 |
} |
| 91 |
|
| 92 |
/// A future that resolves once the object becomes ready for writing |
| 93 |
pub fn writablerust-analyzer cargo calloop 0.10.5 io/impl#[`Async<'l, F>`]writable().<'s>(&'s mut self) -> Writablerust-analyzer cargo calloop 0.10.5 io/Writable#<'s, 'l, F> { |
| 94 |
Writablerust-analyzer cargo calloop 0.10.5 io/Writable# { iorust-analyzer cargo calloop 0.10.5 io/Writable#io.: self } |
| 95 |
} |
| 96 |
|
| 97 |
/// Remove the async adapter and retrieve the underlying object |
| 98 |
pub fn into_innerrust-analyzer cargo calloop 0.10.5 io/impl#[`Async<'l, F>`]into_inner().(mut self) -> F { |
| 99 |
self.fdrust-analyzer cargo calloop 0.10.5 io/Async#fd..takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]take().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().() |
| 100 |
} |
| 101 |
|
| 102 |
fn readinessrust-analyzer cargo calloop 0.10.5 io/impl#[`Async<'l, F>`]readiness().(&self) -> Readinessrust-analyzer cargo calloop 0.10.5 sys/Readiness# { |
| 103 |
self.dispatcherrust-analyzer cargo calloop 0.10.5 io/Async#dispatcher..borrow_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]borrow_mut().().readinessrust-analyzer cargo calloop 0.10.5 io/impl#[IoDispatcher]readiness().() |
| 104 |
} |
| 105 |
|
| 106 |
fn register_wakerrust-analyzer cargo calloop 0.10.5 io/impl#[`Async<'l, F>`]register_waker().(&self, interest: Interestrust-analyzer cargo calloop 0.10.5 sys/Interest#, waker: Wakerrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/wake/Waker#) -> craterust-analyzer cargo calloop 0.10.5 crate/::Resultrust-analyzer cargo calloop 0.10.5 error/Result#<()> { |
| 107 |
{ |
| 108 |
let mut disp = self.dispatcherrust-analyzer cargo calloop 0.10.5 io/Async#dispatcher..borrow_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]borrow_mut().(); |
| 109 |
disp.interestrust-analyzer cargo calloop 0.10.5 io/IoDispatcher#interest. = interest; |
| 110 |
disp.wakerrust-analyzer cargo calloop 0.10.5 io/IoDispatcher#waker. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(waker); |
| 111 |
} |
| 112 |
self.innerrust-analyzer cargo calloop 0.10.5 io/Async#inner..reregisterrust-analyzer cargo calloop 0.10.5 io/IoLoopInner#reregister().(&self.dispatcherrust-analyzer cargo calloop 0.10.5 io/Async#dispatcher.) |
| 113 |
} |
| 114 |
} |
| 115 |
|
| 116 |
/// A future that resolves once the associated object becomes ready for reading |
| 117 |
#[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 118 |
pub struct Readablerust-analyzer cargo calloop 0.10.5 io/Readable#<'s, 'l, F: AsRawFdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/fd/raw/AsRawFd#> { |
| 119 |
iorust-analyzer cargo calloop 0.10.5 io/Readable#io.: &'s mut Asyncrust-analyzer cargo calloop 0.10.5 io/Async#<'l, F>, |
| 120 |
} |
| 121 |
|
| 122 |
impl<'s, 'l, F: AsRawFdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/fd/raw/AsRawFd#> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::futurerust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/::Futurerust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future# for Readablerust-analyzer cargo calloop 0.10.5 io/Readable#<'s, 'l, F> { |
| 123 |
type Outputrust-analyzer cargo calloop 0.10.5 io/impl#[`Readable<'s, 'l, F>`][Future]Output# = (); |
| 124 |
fn pollrust-analyzer cargo calloop 0.10.5 io/impl#[`Readable<'s, 'l, F>`][Future]poll().(mut self: Pinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/Pin#<&mut Selfrust-analyzer cargo calloop 0.10.5 io/impl#[`Readable<'s, 'l, F>`][Future]>, cx: &mut Contextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/wake/Context#<'_>) -> TaskPollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#<()> { |
| 125 |
let io = &mut self.as_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/impl#[`Pin<Ptr>`]as_mut().().iorust-analyzer cargo calloop 0.10.5 io/Readable#io.; |
| 126 |
let readiness = io.readinessrust-analyzer cargo calloop 0.10.5 io/impl#[`Async<'l, F>`]readiness().(); |
| 127 |
if readiness.readablerust-analyzer cargo calloop 0.10.5 sys/Readiness#readable. || readiness.errorrust-analyzer cargo calloop 0.10.5 sys/Readiness#error. { |
| 128 |
TaskPollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#::Readyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#Ready#(()) |
| 129 |
} else { |
| 130 |
let _ = io.register_wakerrust-analyzer cargo calloop 0.10.5 io/impl#[`Async<'l, F>`]register_waker().(Interestrust-analyzer cargo calloop 0.10.5 sys/Interest#::READrust-analyzer cargo calloop 0.10.5 sys/impl#[Interest]READ., cx.wakerrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/wake/impl#[`Context<'a>`]waker().().clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/wake/impl#[Waker][Clone]clone().()); |
| 131 |
TaskPollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#::Pendingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#Pending# |
| 132 |
} |
| 133 |
} |
| 134 |
} |
| 135 |
|
| 136 |
/// A future that resolves once the associated object becomes ready for writing |
| 137 |
#[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 138 |
pub struct Writablerust-analyzer cargo calloop 0.10.5 io/Writable#<'s, 'l, F: AsRawFdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/fd/raw/AsRawFd#> { |
| 139 |
iorust-analyzer cargo calloop 0.10.5 io/Writable#io.: &'s mut Asyncrust-analyzer cargo calloop 0.10.5 io/Async#<'l, F>, |
| 140 |
} |
| 141 |
|
| 142 |
impl<'s, 'l, F: AsRawFdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/fd/raw/AsRawFd#> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::futurerust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/::Futurerust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future# for Writablerust-analyzer cargo calloop 0.10.5 io/Writable#<'s, 'l, F> { |
| 143 |
type Outputrust-analyzer cargo calloop 0.10.5 io/impl#[`Writable<'s, 'l, F>`][Future]Output# = (); |
| 144 |
fn pollrust-analyzer cargo calloop 0.10.5 io/impl#[`Writable<'s, 'l, F>`][Future]poll().(mut self: Pinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/Pin#<&mut Selfrust-analyzer cargo calloop 0.10.5 io/impl#[`Writable<'s, 'l, F>`][Future]>, cx: &mut Contextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/wake/Context#<'_>) -> TaskPollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#<()> { |
| 145 |
let io = &mut self.as_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/impl#[`Pin<Ptr>`]as_mut().().iorust-analyzer cargo calloop 0.10.5 io/Writable#io.; |
| 146 |
let readiness = io.readinessrust-analyzer cargo calloop 0.10.5 io/impl#[`Async<'l, F>`]readiness().(); |
| 147 |
if readiness.writablerust-analyzer cargo calloop 0.10.5 sys/Readiness#writable. || readiness.errorrust-analyzer cargo calloop 0.10.5 sys/Readiness#error. { |
| 148 |
TaskPollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#::Readyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#Ready#(()) |
| 149 |
} else { |
| 150 |
let _ = io.register_wakerrust-analyzer cargo calloop 0.10.5 io/impl#[`Async<'l, F>`]register_waker().(Interestrust-analyzer cargo calloop 0.10.5 sys/Interest#::WRITErust-analyzer cargo calloop 0.10.5 sys/impl#[Interest]WRITE., cx.wakerrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/wake/impl#[`Context<'a>`]waker().().clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/wake/impl#[Waker][Clone]clone().()); |
| 151 |
TaskPollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#::Pendingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#Pending# |
| 152 |
} |
| 153 |
} |
| 154 |
} |
| 155 |
|
| 156 |
impl<'l, F: AsRawFdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/fd/raw/AsRawFd#> Droprust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/drop/Drop# for Asyncrust-analyzer cargo calloop 0.10.5 io/Async#<'l, F> { |
| 157 |
fn droprust-analyzer cargo calloop 0.10.5 io/impl#[`Async<'l, F>`][Drop]drop().(&mut self) { |
| 158 |
self.innerrust-analyzer cargo calloop 0.10.5 io/Async#inner..killrust-analyzer cargo calloop 0.10.5 io/IoLoopInner#kill().(&self.dispatcherrust-analyzer cargo calloop 0.10.5 io/Async#dispatcher.); |
| 159 |
// restore flags |
| 160 |
let _ = fcntlrust-analyzer cargo nix 0.30.1 fcntl/fcntl().( |
| •161 |
unsafe { BorrowedFdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/fd/owned/BorrowedFd#::borrow_rawrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/fd/owned/impl#[`BorrowedFd<'_>`]borrow_raw().(self.dispatcherrust-analyzer cargo calloop 0.10.5 io/Async#dispatcher..borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]borrow().().fdrust-analyzer cargo calloop 0.10.5 io/IoDispatcher#fd.) }, |
| 162 |
FcntlArgrust-analyzer cargo nix 0.30.1 fcntl/FcntlArg#::F_SETFLrust-analyzer cargo nix 0.30.1 fcntl/FcntlArg#F_SETFL#(self.old_flagsrust-analyzer cargo calloop 0.10.5 io/Async#old_flags.), |
| 163 |
); |
| 164 |
} |
| 165 |
} |
| 166 |
|
| 167 |
impl<'l, F: AsRawFdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/fd/raw/AsRawFd#> Unpinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Unpin# for Asyncrust-analyzer cargo calloop 0.10.5 io/Async#<'l, F> {} |
| 168 |
|
| 169 |
trait IoLoopInnerrust-analyzer cargo calloop 0.10.5 io/IoLoopInner# { |
| 170 |
fn registerrust-analyzer cargo calloop 0.10.5 io/IoLoopInner#register().(&self, dispatcher: &RefCellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/RefCell#<IoDispatcherrust-analyzer cargo calloop 0.10.5 io/IoDispatcher#>) -> craterust-analyzer cargo calloop 0.10.5 crate/::Resultrust-analyzer cargo calloop 0.10.5 error/Result#<()>; |
| 171 |
fn reregisterrust-analyzer cargo calloop 0.10.5 io/IoLoopInner#reregister().(&self, dispatcher: &RefCellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/RefCell#<IoDispatcherrust-analyzer cargo calloop 0.10.5 io/IoDispatcher#>) -> craterust-analyzer cargo calloop 0.10.5 crate/::Resultrust-analyzer cargo calloop 0.10.5 error/Result#<()>; |
| 172 |
fn killrust-analyzer cargo calloop 0.10.5 io/IoLoopInner#kill().(&self, dispatcher: &RefCellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/RefCell#<IoDispatcherrust-analyzer cargo calloop 0.10.5 io/IoDispatcher#>); |
| 173 |
} |
| 174 |
|
| 175 |
impl<'l, Data> IoLoopInnerrust-analyzer cargo calloop 0.10.5 io/IoLoopInner# for LoopInnerrust-analyzer cargo calloop 0.10.5 loop_logic/LoopInner#<'l, Data> { |
| 176 |
fn registerrust-analyzer cargo calloop 0.10.5 io/impl#[`LoopInner<'l, Data>`][IoLoopInner]register().(&self, dispatcher: &RefCellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/RefCell#<IoDispatcherrust-analyzer cargo calloop 0.10.5 io/IoDispatcher#>) -> craterust-analyzer cargo calloop 0.10.5 crate/::Resultrust-analyzer cargo calloop 0.10.5 error/Result#<()> { |
| 177 |
let disp = dispatcher.borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]borrow().(); |
| 178 |
self.pollrust-analyzer cargo calloop 0.10.5 loop_logic/LoopInner#poll..borrow_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]borrow_mut().().registerrust-analyzer cargo calloop 0.10.5 sys/impl#[Poll]register().( |
| 179 |
disp.fdrust-analyzer cargo calloop 0.10.5 io/IoDispatcher#fd., |
| 180 |
Interestrust-analyzer cargo calloop 0.10.5 sys/Interest#::EMPTYrust-analyzer cargo calloop 0.10.5 sys/impl#[Interest]EMPTY., |
| 181 |
Moderust-analyzer cargo calloop 0.10.5 sys/Mode#::OneShotrust-analyzer cargo calloop 0.10.5 sys/Mode#OneShot#, |
| 182 |
disp.tokenrust-analyzer cargo calloop 0.10.5 io/IoDispatcher#token..expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("No token for IO dispatcher"), |
| 183 |
) |
| 184 |
} |
| 185 |
|
| 186 |
fn reregisterrust-analyzer cargo calloop 0.10.5 io/impl#[`LoopInner<'l, Data>`][IoLoopInner]reregister().(&self, dispatcher: &RefCellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/RefCell#<IoDispatcherrust-analyzer cargo calloop 0.10.5 io/IoDispatcher#>) -> craterust-analyzer cargo calloop 0.10.5 crate/::Resultrust-analyzer cargo calloop 0.10.5 error/Result#<()> { |
| 187 |
let disp = dispatcher.borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]borrow().(); |
| 188 |
self.pollrust-analyzer cargo calloop 0.10.5 loop_logic/LoopInner#poll..borrow_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]borrow_mut().().reregisterrust-analyzer cargo calloop 0.10.5 sys/impl#[Poll]reregister().( |
| 189 |
disp.fdrust-analyzer cargo calloop 0.10.5 io/IoDispatcher#fd., |
| 190 |
disp.interestrust-analyzer cargo calloop 0.10.5 io/IoDispatcher#interest., |
| 191 |
Moderust-analyzer cargo calloop 0.10.5 sys/Mode#::OneShotrust-analyzer cargo calloop 0.10.5 sys/Mode#OneShot#, |
| 192 |
disp.tokenrust-analyzer cargo calloop 0.10.5 io/IoDispatcher#token..expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("No token for IO dispatcher"), |
| 193 |
) |
| 194 |
} |
| 195 |
|
| 196 |
fn killrust-analyzer cargo calloop 0.10.5 io/impl#[`LoopInner<'l, Data>`][IoLoopInner]kill().(&self, dispatcher: &RefCellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/RefCell#<IoDispatcherrust-analyzer cargo calloop 0.10.5 io/IoDispatcher#>) { |
| 197 |
let key = dispatcher |
| 198 |
.borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]borrow().() |
| 199 |
.tokenrust-analyzer cargo calloop 0.10.5 io/IoDispatcher#token. |
| 200 |
.expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("No token for IO dispatcher") |
| 201 |
.keyrust-analyzer cargo calloop 0.10.5 sys/Token#key.; |
| 202 |
let _source = self |
| 203 |
.sourcesrust-analyzer cargo calloop 0.10.5 loop_logic/LoopInner#sources. |
| 204 |
.borrow_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]borrow_mut().() |
| 205 |
.removerust-analyzer cargo slotmap 1.0.6 basic/impl#[`SlotMap<K, V>`]remove().(key) |
| 206 |
.expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("Attempting to remove a non-existent source?!"); |
| 207 |
} |
| 208 |
} |
| 209 |
|
| 210 |
struct IoDispatcherrust-analyzer cargo calloop 0.10.5 io/IoDispatcher# { |
| 211 |
fdrust-analyzer cargo calloop 0.10.5 io/IoDispatcher#fd.: RawFdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/fd/raw/RawFd#, |
| 212 |
tokenrust-analyzer cargo calloop 0.10.5 io/IoDispatcher#token.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Tokenrust-analyzer cargo calloop 0.10.5 sys/Token#>, |
| 213 |
wakerrust-analyzer cargo calloop 0.10.5 io/IoDispatcher#waker.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Wakerrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/wake/Waker#>, |
| 214 |
is_registeredrust-analyzer cargo calloop 0.10.5 io/IoDispatcher#is_registered.: bool, |
| 215 |
interestrust-analyzer cargo calloop 0.10.5 io/IoDispatcher#interest.: Interestrust-analyzer cargo calloop 0.10.5 sys/Interest#, |
| 216 |
last_readinessrust-analyzer cargo calloop 0.10.5 io/IoDispatcher#last_readiness.: Readinessrust-analyzer cargo calloop 0.10.5 sys/Readiness#, |
| 217 |
} |
| 218 |
|
| 219 |
impl IoDispatcherrust-analyzer cargo calloop 0.10.5 io/IoDispatcher# { |
| 220 |
fn readinessrust-analyzer cargo calloop 0.10.5 io/impl#[IoDispatcher]readiness().(&mut self) -> Readinessrust-analyzer cargo calloop 0.10.5 sys/Readiness# { |
| 221 |
stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::replacerust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/replace().(&mut self.last_readinessrust-analyzer cargo calloop 0.10.5 io/IoDispatcher#last_readiness., Readinessrust-analyzer cargo calloop 0.10.5 sys/Readiness#::EMPTYrust-analyzer cargo calloop 0.10.5 sys/impl#[Readiness]EMPTY.) |
| 222 |
} |
| 223 |
} |
| 224 |
|
| 225 |
impl<Data> EventDispatcherrust-analyzer cargo calloop 0.10.5 sources/EventDispatcher#<Data> for RefCellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/RefCell#<IoDispatcherrust-analyzer cargo calloop 0.10.5 io/IoDispatcher#> { |
| 226 |
fn process_eventsrust-analyzer cargo calloop 0.10.5 io/impl#[`RefCell<IoDispatcher>`][`EventDispatcher<Data>`]process_events().( |
| 227 |
&self, |
| 228 |
readiness: Readinessrust-analyzer cargo calloop 0.10.5 sys/Readiness#, |
| 229 |
_token: Tokenrust-analyzer cargo calloop 0.10.5 sys/Token#, |
| 230 |
_data: &mut Data, |
| 231 |
) -> craterust-analyzer cargo calloop 0.10.5 crate/::Resultrust-analyzer cargo calloop 0.10.5 error/Result#<PostActionrust-analyzer cargo calloop 0.10.5 sources/PostAction#> { |
| 232 |
let mut disp = self.borrow_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]borrow_mut().(); |
| 233 |
disp.last_readinessrust-analyzer cargo calloop 0.10.5 io/IoDispatcher#last_readiness. = readiness; |
| 234 |
if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(waker) = disp.wakerrust-analyzer cargo calloop 0.10.5 io/IoDispatcher#waker..takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]take().() { |
| 235 |
waker.wakerust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/wake/impl#[Waker]wake().(); |
| 236 |
} |
| 237 |
Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(PostActionrust-analyzer cargo calloop 0.10.5 sources/PostAction#::Continuerust-analyzer cargo calloop 0.10.5 sources/PostAction#Continue#) |
| 238 |
} |
| 239 |
|
| 240 |
fn registerrust-analyzer cargo calloop 0.10.5 io/impl#[`RefCell<IoDispatcher>`][`EventDispatcher<Data>`]register().(&self, _: &mut Pollrust-analyzer cargo calloop 0.10.5 sys/Poll#, _: &mut TokenFactoryrust-analyzer cargo calloop 0.10.5 sys/TokenFactory#) -> craterust-analyzer cargo calloop 0.10.5 crate/::Resultrust-analyzer cargo calloop 0.10.5 error/Result#<()> { |
| 241 |
// registration is handled by IoLoopInner |
| 242 |
unreachablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/unreachable!!() |
| 243 |
} |
| 244 |
|
| 245 |
fn reregisterrust-analyzer cargo calloop 0.10.5 io/impl#[`RefCell<IoDispatcher>`][`EventDispatcher<Data>`]reregister().(&self, _: &mut Pollrust-analyzer cargo calloop 0.10.5 sys/Poll#, _: &mut TokenFactoryrust-analyzer cargo calloop 0.10.5 sys/TokenFactory#) -> craterust-analyzer cargo calloop 0.10.5 crate/::Resultrust-analyzer cargo calloop 0.10.5 error/Result#<bool> { |
| 246 |
// registration is handled by IoLoopInner |
| 247 |
unreachablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/unreachable!!() |
| 248 |
} |
| 249 |
|
| 250 |
fn unregisterrust-analyzer cargo calloop 0.10.5 io/impl#[`RefCell<IoDispatcher>`][`EventDispatcher<Data>`]unregister().(&self, poll: &mut Pollrust-analyzer cargo calloop 0.10.5 sys/Poll#) -> craterust-analyzer cargo calloop 0.10.5 crate/::Resultrust-analyzer cargo calloop 0.10.5 error/Result#<bool> { |
| 251 |
let disp = self.borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`RefCell<T>`]borrow().(); |
| 252 |
if disp.is_registeredrust-analyzer cargo calloop 0.10.5 io/IoDispatcher#is_registered. { |
| 253 |
poll.unregisterrust-analyzer cargo calloop 0.10.5 sys/impl#[Poll]unregister().(disp.fdrust-analyzer cargo calloop 0.10.5 io/IoDispatcher#fd.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 254 |
} |
| 255 |
Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(true) |
| 256 |
} |
| 257 |
|
| 258 |
fn pre_runrust-analyzer cargo calloop 0.10.5 io/impl#[`RefCell<IoDispatcher>`][`EventDispatcher<Data>`]pre_run().(&self, _data: &mut Data) -> craterust-analyzer cargo calloop 0.10.5 crate/::Resultrust-analyzer cargo calloop 0.10.5 error/Result#<()> { |
| 259 |
Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 260 |
} |
| 261 |
fn post_runrust-analyzer cargo calloop 0.10.5 io/impl#[`RefCell<IoDispatcher>`][`EventDispatcher<Data>`]post_run().(&self, _data: &mut Data) -> craterust-analyzer cargo calloop 0.10.5 crate/::Resultrust-analyzer cargo calloop 0.10.5 error/Result#<()> { |
| 262 |
Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 263 |
} |
| 264 |
} |
| 265 |
|
| 266 |
/* |
| 267 |
* Async IO trait implementations |
| 268 |
*/ |
| 269 |
|
| 270 |
#[cfg(feature = "futures-io")] |
| 271 |
#[cfg_attr(docsrs, doc(cfg(feature = "futures-io")))] |
| 272 |
impl<'l, F: AsRawFdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/fd/raw/AsRawFd# + stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#> AsyncReadrust-analyzer cargo futures-io 0.3.25 if_std/AsyncRead# for Asyncrust-analyzer cargo calloop 0.10.5 io/Async#<'l, F> { |
| 273 |
fn poll_readrust-analyzer cargo calloop 0.10.5 io/impl#[`Async<'l, F>`][AsyncRead]poll_read().( |
| 274 |
mut self: Pinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/Pin#<&mut Selfrust-analyzer cargo calloop 0.10.5 io/impl#[`Async<'l, F>`][AsyncRead]>, |
| 275 |
cx: &mut Contextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/wake/Context#<'_>, |
| 276 |
buf: &mut [u8], |
| 277 |
) -> TaskPollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#<stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<usize>> { |
| 278 |
match (*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/impl#[`Pin<Ptr>`][DerefMut]deref_mut().self).get_mutrust-analyzer cargo calloop 0.10.5 io/impl#[`Async<'l, F>`]get_mut().().readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#read().(buf) { |
| 279 |
Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(err) if err.kindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error]kind().() rust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[ErrorKind][`PartialEq<Self>`]eq().==rust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[ErrorKind][`PartialEq<Self>`]eq(). rust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[ErrorKind][`PartialEq<Self>`]eq().stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::ErrorKindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#::WouldBlockrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#WouldBlock# => {} |
| 280 |
res => return TaskPollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#::Readyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#Ready#(res), |
| 281 |
} |
| 282 |
self.register_wakerrust-analyzer cargo calloop 0.10.5 io/impl#[`Async<'l, F>`]register_waker().(Interestrust-analyzer cargo calloop 0.10.5 sys/Interest#::READrust-analyzer cargo calloop 0.10.5 sys/impl#[Interest]READ., cx.wakerrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/wake/impl#[`Context<'a>`]waker().().clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/wake/impl#[Waker][Clone]clone().())?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 283 |
TaskPollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#::Pendingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#Pending# |
| 284 |
} |
| 285 |
|
| 286 |
fn poll_read_vectoredrust-analyzer cargo calloop 0.10.5 io/impl#[`Async<'l, F>`][AsyncRead]poll_read_vectored().( |
| 287 |
mut self: Pinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/Pin#<&mut Selfrust-analyzer cargo calloop 0.10.5 io/impl#[`Async<'l, F>`][AsyncRead]>, |
| 288 |
cx: &mut Contextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/wake/Context#<'_>, |
| 289 |
bufs: &mut [IoSliceMutrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/IoSliceMut#<'_>], |
| 290 |
) -> TaskPollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#<stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<usize>> { |
| 291 |
match (*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/impl#[`Pin<Ptr>`][DerefMut]deref_mut().self).get_mutrust-analyzer cargo calloop 0.10.5 io/impl#[`Async<'l, F>`]get_mut().().read_vectoredrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#read_vectored().(bufs) { |
| 292 |
Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(err) if err.kindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error]kind().() rust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[ErrorKind][`PartialEq<Self>`]eq().==rust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[ErrorKind][`PartialEq<Self>`]eq(). rust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[ErrorKind][`PartialEq<Self>`]eq().stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::ErrorKindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#::WouldBlockrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#WouldBlock# => {} |
| 293 |
res => return TaskPollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#::Readyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#Ready#(res), |
| 294 |
} |
| 295 |
self.register_wakerrust-analyzer cargo calloop 0.10.5 io/impl#[`Async<'l, F>`]register_waker().(Interestrust-analyzer cargo calloop 0.10.5 sys/Interest#::READrust-analyzer cargo calloop 0.10.5 sys/impl#[Interest]READ., cx.wakerrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/wake/impl#[`Context<'a>`]waker().().clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/wake/impl#[Waker][Clone]clone().())?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 296 |
TaskPollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#::Pendingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#Pending# |
| 297 |
} |
| 298 |
} |
| 299 |
|
| 300 |
#[cfg(feature = "futures-io")] |
| 301 |
#[cfg_attr(docsrs, doc(cfg(feature = "futures-io")))] |
| 302 |
impl<'l, F: AsRawFdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/fd/raw/AsRawFd# + stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#> AsyncWriterust-analyzer cargo futures-io 0.3.25 if_std/AsyncWrite# for Asyncrust-analyzer cargo calloop 0.10.5 io/Async#<'l, F> { |
| 303 |
fn poll_writerust-analyzer cargo calloop 0.10.5 io/impl#[`Async<'l, F>`][AsyncWrite]poll_write().( |
| 304 |
mut self: Pinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/Pin#<&mut Selfrust-analyzer cargo calloop 0.10.5 io/impl#[`Async<'l, F>`][AsyncWrite]>, |
| 305 |
cx: &mut Contextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/wake/Context#<'_>, |
| 306 |
buf: &[u8], |
| 307 |
) -> TaskPollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#<stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<usize>> { |
| 308 |
match (*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/impl#[`Pin<Ptr>`][DerefMut]deref_mut().self).get_mutrust-analyzer cargo calloop 0.10.5 io/impl#[`Async<'l, F>`]get_mut().().writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#write().(buf) { |
| 309 |
Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(err) if err.kindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error]kind().() rust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[ErrorKind][`PartialEq<Self>`]eq().==rust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[ErrorKind][`PartialEq<Self>`]eq(). rust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[ErrorKind][`PartialEq<Self>`]eq().stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::ErrorKindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#::WouldBlockrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#WouldBlock# => {} |
| 310 |
res => return TaskPollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#::Readyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#Ready#(res), |
| 311 |
} |
| 312 |
self.register_wakerrust-analyzer cargo calloop 0.10.5 io/impl#[`Async<'l, F>`]register_waker().(Interestrust-analyzer cargo calloop 0.10.5 sys/Interest#::WRITErust-analyzer cargo calloop 0.10.5 sys/impl#[Interest]WRITE., cx.wakerrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/wake/impl#[`Context<'a>`]waker().().clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/wake/impl#[Waker][Clone]clone().())?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 313 |
TaskPollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#::Pendingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#Pending# |
| 314 |
} |
| 315 |
|
| 316 |
fn poll_write_vectoredrust-analyzer cargo calloop 0.10.5 io/impl#[`Async<'l, F>`][AsyncWrite]poll_write_vectored().( |
| 317 |
mut self: Pinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/Pin#<&mut Selfrust-analyzer cargo calloop 0.10.5 io/impl#[`Async<'l, F>`][AsyncWrite]>, |
| 318 |
cx: &mut Contextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/wake/Context#<'_>, |
| 319 |
bufs: &[IoSlicerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/IoSlice#<'_>], |
| 320 |
) -> TaskPollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#<stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<usize>> { |
| 321 |
match (*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/impl#[`Pin<Ptr>`][DerefMut]deref_mut().self).get_mutrust-analyzer cargo calloop 0.10.5 io/impl#[`Async<'l, F>`]get_mut().().write_vectoredrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#write_vectored().(bufs) { |
| 322 |
Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(err) if err.kindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error]kind().() rust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[ErrorKind][`PartialEq<Self>`]eq().==rust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[ErrorKind][`PartialEq<Self>`]eq(). rust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[ErrorKind][`PartialEq<Self>`]eq().stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::ErrorKindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#::WouldBlockrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#WouldBlock# => {} |
| 323 |
res => return TaskPollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#::Readyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#Ready#(res), |
| 324 |
} |
| 325 |
self.register_wakerrust-analyzer cargo calloop 0.10.5 io/impl#[`Async<'l, F>`]register_waker().(Interestrust-analyzer cargo calloop 0.10.5 sys/Interest#::WRITErust-analyzer cargo calloop 0.10.5 sys/impl#[Interest]WRITE., cx.wakerrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/wake/impl#[`Context<'a>`]waker().().clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/wake/impl#[Waker][Clone]clone().())?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 326 |
TaskPollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#::Pendingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#Pending# |
| 327 |
} |
| 328 |
|
| 329 |
fn poll_flushrust-analyzer cargo calloop 0.10.5 io/impl#[`Async<'l, F>`][AsyncWrite]poll_flush().(mut self: Pinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/Pin#<&mut Selfrust-analyzer cargo calloop 0.10.5 io/impl#[`Async<'l, F>`][AsyncWrite]>, cx: &mut Contextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/wake/Context#<'_>) -> TaskPollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#<stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()>> { |
| 330 |
match (*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/impl#[`Pin<Ptr>`][DerefMut]deref_mut().self).get_mutrust-analyzer cargo calloop 0.10.5 io/impl#[`Async<'l, F>`]get_mut().().flushrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#flush().() { |
| 331 |
Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(err) if err.kindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error]kind().() rust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[ErrorKind][`PartialEq<Self>`]eq().==rust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[ErrorKind][`PartialEq<Self>`]eq(). rust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[ErrorKind][`PartialEq<Self>`]eq().stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::ErrorKindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#::WouldBlockrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#WouldBlock# => {} |
| 332 |
res => return TaskPollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#::Readyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#Ready#(res), |
| 333 |
} |
| 334 |
self.register_wakerrust-analyzer cargo calloop 0.10.5 io/impl#[`Async<'l, F>`]register_waker().(Interestrust-analyzer cargo calloop 0.10.5 sys/Interest#::WRITErust-analyzer cargo calloop 0.10.5 sys/impl#[Interest]WRITE., cx.wakerrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/wake/impl#[`Context<'a>`]waker().().clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/wake/impl#[Waker][Clone]clone().())?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 335 |
TaskPollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#::Pendingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#Pending# |
| 336 |
} |
| 337 |
|
| 338 |
fn poll_closerust-analyzer cargo calloop 0.10.5 io/impl#[`Async<'l, F>`][AsyncWrite]poll_close().(self: Pinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core pin/Pin#<&mut Selfrust-analyzer cargo calloop 0.10.5 io/impl#[`Async<'l, F>`][AsyncWrite]>, cx: &mut Contextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/wake/Context#<'_>) -> TaskPollrust-analyzer cargo core https://github.com/rust-lang/rust/library/core task/poll/Poll#<stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()>> { |
| 339 |
self.poll_flushrust-analyzer cargo calloop 0.10.5 io/impl#[`Async<'l, F>`][AsyncWrite]poll_flush().(cx) |
| 340 |
} |
| 341 |
} |
| 342 |
|
| 343 |
#[cfg(all(test, feature = "executor", feature = "futures-io"))] |
| 344 |
mod testsrust-analyzer cargo calloop 0.10.5 io/tests/ { |
| 345 |
use futuresrust-analyzer cargo futures 0.3.25 crate/::iorust-analyzer cargo futures-util 0.3.25 io/::{AsyncReadExtrust-analyzer cargo futures-util 0.3.25 io/AsyncReadExt#, AsyncWriteExtrust-analyzer cargo futures-util 0.3.25 io/AsyncWriteExt#}; |
| 346 |
|
| 347 |
use craterust-analyzer cargo calloop 0.10.5 crate/::sourcesrust-analyzer cargo calloop 0.10.5 sources/::futuresrust-analyzer cargo calloop 0.10.5 sources/futures/::executorrust-analyzer cargo calloop 0.10.5 sources/futures/executor().; |
| 348 |
|
| 349 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 350 |
fn read_writerust-analyzer cargo calloop 0.10.5 io/tests/read_write().() { |
| 351 |
let mut event_loop = craterust-analyzer cargo calloop 0.10.5 crate/::EventLooprust-analyzer cargo calloop 0.10.5 loop_logic/EventLoop#::try_newrust-analyzer cargo calloop 0.10.5 loop_logic/impl#[`EventLoop<'l, Data>`]try_new().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 352 |
let handle = event_loop.handlerust-analyzer cargo calloop 0.10.5 loop_logic/impl#[`EventLoop<'l, Data>`]handle().(); |
| 353 |
let (exec, sched) = executorrust-analyzer cargo calloop 0.10.5 sources/futures/executor().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 354 |
handle |
| 355 |
.insert_sourcerust-analyzer cargo calloop 0.10.5 loop_logic/impl#[`LoopHandle<'l, Data>`]insert_source().(exec, move |ret, &mut (), got| { |
| 356 |
*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().got = ret; |
| 357 |
}) |
| 358 |
.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 359 |
|
| 360 |
let (tx, rx) = stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::osrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/::unixrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/unix/::netrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/unix/net/::UnixStreamrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/unix/net/stream/UnixStream#::pairrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/unix/net/stream/impl#[UnixStream]pair().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 361 |
let mut tx = handle.adapt_iorust-analyzer cargo calloop 0.10.5 loop_logic/impl#[`LoopHandle<'l, Data>`]adapt_io().(tx).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 362 |
let mut rx = handle.adapt_iorust-analyzer cargo calloop 0.10.5 loop_logic/impl#[`LoopHandle<'l, Data>`]adapt_io().(rx).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 363 |
let received = stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::rcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/::Rcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/Rc#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/impl#[`Rc<T>`]new().(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::cellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/::Cellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/Cell#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`Cell<T>`]new().(false)); |
| 364 |
let fut_received = received.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/impl#[`Rc<T, A>`][Clone]clone().(); |
| 365 |
|
| 366 |
sched |
| 367 |
.schedulerust-analyzer cargo calloop 0.10.5 sources/futures/impl#[`Scheduler<T>`]schedule().(async move { |
| 368 |
let mut buf = [0; 12]; |
| 369 |
rx.read_exactrust-analyzer cargo futures-util 0.3.25 io/AsyncReadExt#read_exact().(&mut buf).rust-analyzer cargo futures-util 0.3.25 io/read_exact/impl#[`ReadExact<'_, R>`][Future]poll().awaitrust-analyzer cargo futures-util 0.3.25 io/read_exact/impl#[`ReadExact<'_, R>`][Future]poll()..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 370 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf, b"Hello World!"); |
| 371 |
fut_received.setrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`Cell<T>`]set().(true); |
| 372 |
}) |
| 373 |
.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 374 |
|
| 375 |
// The receiving future alone cannot advance |
| 376 |
event_loop |
| 377 |
.dispatchrust-analyzer cargo calloop 0.10.5 loop_logic/impl#[`EventLoop<'l, Data>`]dispatch().(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::timerust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/::Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#::from_millisrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration]from_millis().(10)), &mut ()) |
| 378 |
.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 379 |
assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().received.getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`Cell<T>`]get().()); |
| 380 |
|
| 381 |
// schedule the writing future as well and wait until finish |
| 382 |
sched |
| 383 |
.schedulerust-analyzer cargo calloop 0.10.5 sources/futures/impl#[`Scheduler<T>`]schedule().(async move { |
| 384 |
tx.write_allrust-analyzer cargo futures-util 0.3.25 io/AsyncWriteExt#write_all().(b"Hello World!").rust-analyzer cargo futures-util 0.3.25 io/write_all/impl#[`WriteAll<'_, W>`][Future]poll().awaitrust-analyzer cargo futures-util 0.3.25 io/write_all/impl#[`WriteAll<'_, W>`][Future]poll()..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 385 |
tx.flushrust-analyzer cargo futures-util 0.3.25 io/AsyncWriteExt#flush().().rust-analyzer cargo futures-util 0.3.25 io/flush/impl#[`Flush<'_, W>`][Future]poll().awaitrust-analyzer cargo futures-util 0.3.25 io/flush/impl#[`Flush<'_, W>`][Future]poll()..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 386 |
}) |
| 387 |
.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 388 |
|
| 389 |
while !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().received.getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`Cell<T>`]get().() { |
| 390 |
event_loop.dispatchrust-analyzer cargo calloop 0.10.5 loop_logic/impl#[`EventLoop<'l, Data>`]dispatch().(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, &mut ()).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 391 |
} |
| 392 |
} |
| 393 |
|
| 394 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 395 |
fn read_write_vectoredrust-analyzer cargo calloop 0.10.5 io/tests/read_write_vectored().() { |
| 396 |
let mut event_loop = craterust-analyzer cargo calloop 0.10.5 crate/::EventLooprust-analyzer cargo calloop 0.10.5 loop_logic/EventLoop#::try_newrust-analyzer cargo calloop 0.10.5 loop_logic/impl#[`EventLoop<'l, Data>`]try_new().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 397 |
let handle = event_loop.handlerust-analyzer cargo calloop 0.10.5 loop_logic/impl#[`EventLoop<'l, Data>`]handle().(); |
| 398 |
let (exec, sched) = executorrust-analyzer cargo calloop 0.10.5 sources/futures/executor().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 399 |
handle |
| 400 |
.insert_sourcerust-analyzer cargo calloop 0.10.5 loop_logic/impl#[`LoopHandle<'l, Data>`]insert_source().(exec, move |ret, &mut (), got| { |
| 401 |
*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().got = ret; |
| 402 |
}) |
| 403 |
.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 404 |
|
| 405 |
let (tx, rx) = stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::osrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/::unixrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/unix/::netrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/unix/net/::UnixStreamrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/unix/net/stream/UnixStream#::pairrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/unix/net/stream/impl#[UnixStream]pair().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 406 |
let mut tx = handle.adapt_iorust-analyzer cargo calloop 0.10.5 loop_logic/impl#[`LoopHandle<'l, Data>`]adapt_io().(tx).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 407 |
let mut rx = handle.adapt_iorust-analyzer cargo calloop 0.10.5 loop_logic/impl#[`LoopHandle<'l, Data>`]adapt_io().(rx).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 408 |
let received = stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::rcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/::Rcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/Rc#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/impl#[`Rc<T>`]new().(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::cellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/::Cellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/Cell#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`Cell<T>`]new().(false)); |
| 409 |
let fut_received = received.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/impl#[`Rc<T, A>`][Clone]clone().(); |
| 410 |
|
| 411 |
sched |
| 412 |
.schedulerust-analyzer cargo calloop 0.10.5 sources/futures/impl#[`Scheduler<T>`]schedule().(async move { |
| 413 |
let mut buf = [0; 12]; |
| 414 |
let mut ioslices = buf |
| 415 |
.chunks_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks_mut().(2) |
| 416 |
.maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::IoSliceMutrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/IoSliceMut#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/impl#[`IoSliceMut<'a>`]new().) |
| 417 |
.collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>(); |
| 418 |
let count = rx.read_vectoredrust-analyzer cargo futures-util 0.3.25 io/AsyncReadExt#read_vectored().(&mut ioslices).rust-analyzer cargo futures-util 0.3.25 io/read_vectored/impl#[`ReadVectored<'_, R>`][Future]poll().awaitrust-analyzer cargo futures-util 0.3.25 io/read_vectored/impl#[`ReadVectored<'_, R>`][Future]poll()..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 419 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(count, 12); |
| 420 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&buf, b"Hello World!"); |
| 421 |
fut_received.setrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`Cell<T>`]set().(true); |
| 422 |
}) |
| 423 |
.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 424 |
|
| 425 |
// The receiving future alone cannot advance |
| 426 |
event_loop |
| 427 |
.dispatchrust-analyzer cargo calloop 0.10.5 loop_logic/impl#[`EventLoop<'l, Data>`]dispatch().(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::timerust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/::Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#::from_millisrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration]from_millis().(10)), &mut ()) |
| 428 |
.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 429 |
assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().received.getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`Cell<T>`]get().()); |
| 430 |
|
| 431 |
// schedule the writing future as well and wait until finish |
| 432 |
sched |
| 433 |
.schedulerust-analyzer cargo calloop 0.10.5 sources/futures/impl#[`Scheduler<T>`]schedule().(async move { |
| 434 |
let buf = b"Hello World!"; |
| 435 |
let ioslices = buf.chunksrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]chunks().(2).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::IoSlicerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/IoSlice#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/impl#[`IoSlice<'a>`]new().).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>(); |
| 436 |
let count = tx.write_vectoredrust-analyzer cargo futures-util 0.3.25 io/AsyncWriteExt#write_vectored().(&ioslices).rust-analyzer cargo futures-util 0.3.25 io/write_vectored/impl#[`WriteVectored<'_, W>`][Future]poll().awaitrust-analyzer cargo futures-util 0.3.25 io/write_vectored/impl#[`WriteVectored<'_, W>`][Future]poll()..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 437 |
assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(count, 12); |
| 438 |
tx.flushrust-analyzer cargo futures-util 0.3.25 io/AsyncWriteExt#flush().().rust-analyzer cargo futures-util 0.3.25 io/flush/impl#[`Flush<'_, W>`][Future]poll().awaitrust-analyzer cargo futures-util 0.3.25 io/flush/impl#[`Flush<'_, W>`][Future]poll()..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 439 |
}) |
| 440 |
.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 441 |
|
| 442 |
while !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().received.getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`Cell<T>`]get().() { |
| 443 |
event_loop.dispatchrust-analyzer cargo calloop 0.10.5 loop_logic/impl#[`EventLoop<'l, Data>`]dispatch().(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, &mut ()).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 444 |
} |
| 445 |
} |
| 446 |
|
| 447 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 448 |
fn readablerust-analyzer cargo calloop 0.10.5 io/tests/readable().() { |
| 449 |
use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#; |
| 450 |
|
| 451 |
let mut event_loop = craterust-analyzer cargo calloop 0.10.5 crate/::EventLooprust-analyzer cargo calloop 0.10.5 loop_logic/EventLoop#::try_newrust-analyzer cargo calloop 0.10.5 loop_logic/impl#[`EventLoop<'l, Data>`]try_new().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 452 |
let handle = event_loop.handlerust-analyzer cargo calloop 0.10.5 loop_logic/impl#[`EventLoop<'l, Data>`]handle().(); |
| 453 |
let (exec, sched) = executorrust-analyzer cargo calloop 0.10.5 sources/futures/executor().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 454 |
handle |
| 455 |
.insert_sourcerust-analyzer cargo calloop 0.10.5 loop_logic/impl#[`LoopHandle<'l, Data>`]insert_source().(exec, move |(), &mut (), got| { |
| 456 |
*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().got = true; |
| 457 |
}) |
| 458 |
.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 459 |
|
| 460 |
let (mut tx, rx) = stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::osrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/::unixrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/unix/::netrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/unix/net/::UnixStreamrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/unix/net/stream/UnixStream#::pairrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/unix/net/stream/impl#[UnixStream]pair().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 461 |
|
| 462 |
let mut rx = handle.adapt_iorust-analyzer cargo calloop 0.10.5 loop_logic/impl#[`LoopHandle<'l, Data>`]adapt_io().(rx).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 463 |
sched |
| 464 |
.schedulerust-analyzer cargo calloop 0.10.5 sources/futures/impl#[`Scheduler<T>`]schedule().(async move { |
| 465 |
rx.readablerust-analyzer cargo calloop 0.10.5 io/impl#[`Async<'l, F>`]readable().().rust-analyzer cargo calloop 0.10.5 io/impl#[`Readable<'s, 'l, F>`][Future]poll().awaitrust-analyzer cargo calloop 0.10.5 io/impl#[`Readable<'s, 'l, F>`][Future]poll().; |
| 466 |
}) |
| 467 |
.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 468 |
|
| 469 |
let mut dispatched = false; |
| 470 |
|
| 471 |
event_loop |
| 472 |
.dispatchrust-analyzer cargo calloop 0.10.5 loop_logic/impl#[`EventLoop<'l, Data>`]dispatch().(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::timerust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/::Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#::from_millisrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration]from_millis().(100)), &mut dispatched) |
| 473 |
.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 474 |
// The socket is not yet readable, so the readable() future has not completed |
| 475 |
assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().dispatched); |
| 476 |
|
| 477 |
tx.write_allrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#write_all().(&[42]).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 478 |
tx.flushrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/unix/net/stream/impl#[UnixStream][Write]flush().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 479 |
|
| 480 |
// Now we should become readable |
| 481 |
while !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().dispatched { |
| 482 |
event_loop.dispatchrust-analyzer cargo calloop 0.10.5 loop_logic/impl#[`EventLoop<'l, Data>`]dispatch().(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, &mut dispatched).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 483 |
} |
| 484 |
} |
| 485 |
|
| 486 |
#[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 487 |
fn writablerust-analyzer cargo calloop 0.10.5 io/tests/writable().() { |
| 488 |
use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::{BufReaderrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/buffered/bufreader/BufReader#, BufWriterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/buffered/bufwriter/BufWriter#, Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#, Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#}; |
| 489 |
|
| 490 |
let mut event_loop = craterust-analyzer cargo calloop 0.10.5 crate/::EventLooprust-analyzer cargo calloop 0.10.5 loop_logic/EventLoop#::try_newrust-analyzer cargo calloop 0.10.5 loop_logic/impl#[`EventLoop<'l, Data>`]try_new().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 491 |
let handle = event_loop.handlerust-analyzer cargo calloop 0.10.5 loop_logic/impl#[`EventLoop<'l, Data>`]handle().(); |
| 492 |
let (exec, sched) = executorrust-analyzer cargo calloop 0.10.5 sources/futures/executor().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 493 |
handle |
| 494 |
.insert_sourcerust-analyzer cargo calloop 0.10.5 loop_logic/impl#[`LoopHandle<'l, Data>`]insert_source().(exec, move |(), &mut (), got| { |
| 495 |
*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().got = true; |
| 496 |
}) |
| 497 |
.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 498 |
|
| 499 |
let (mut tx, mut rx) = stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::osrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/::unixrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/unix/::netrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/unix/net/::UnixStreamrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/unix/net/stream/UnixStream#::pairrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/unix/net/stream/impl#[UnixStream]pair().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 500 |
tx.set_nonblockingrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/unix/net/stream/impl#[UnixStream]set_nonblocking().(true).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 501 |
rx.set_nonblockingrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/unix/net/stream/impl#[UnixStream]set_nonblocking().(true).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 502 |
|
| 503 |
// First, fill the socket buffers |
| 504 |
{ |
| 505 |
let mut writer = BufWriterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/buffered/bufwriter/BufWriter#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/buffered/bufwriter/impl#[`BufWriter<W>`]new().(&mut tx); |
| 506 |
let data = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![42u8; 1024]; |
| 507 |
loop { |
| 508 |
if writer.writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/buffered/bufwriter/impl#[`BufWriter<W>`][Write]write().(&data).is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().() { |
| 509 |
break; |
| 510 |
} |
| 511 |
} |
| 512 |
} |
| 513 |
|
| 514 |
// Now, wait for it to be readable |
| 515 |
let mut tx = handle.adapt_iorust-analyzer cargo calloop 0.10.5 loop_logic/impl#[`LoopHandle<'l, Data>`]adapt_io().(tx).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 516 |
sched |
| 517 |
.schedulerust-analyzer cargo calloop 0.10.5 sources/futures/impl#[`Scheduler<T>`]schedule().(async move { |
| 518 |
tx.writablerust-analyzer cargo calloop 0.10.5 io/impl#[`Async<'l, F>`]writable().().rust-analyzer cargo calloop 0.10.5 io/impl#[`Writable<'s, 'l, F>`][Future]poll().awaitrust-analyzer cargo calloop 0.10.5 io/impl#[`Writable<'s, 'l, F>`][Future]poll().; |
| 519 |
}) |
| 520 |
.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 521 |
|
| 522 |
let mut dispatched = false; |
| 523 |
|
| 524 |
event_loop |
| 525 |
.dispatchrust-analyzer cargo calloop 0.10.5 loop_logic/impl#[`EventLoop<'l, Data>`]dispatch().(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::timerust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/::Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#::from_millisrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration]from_millis().(100)), &mut dispatched) |
| 526 |
.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 527 |
// The socket is not yet writable, so the readable() future has not completed |
| 528 |
assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().dispatched); |
| 529 |
|
| 530 |
// now read everything |
| 531 |
{ |
| 532 |
let mut reader = BufReaderrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/buffered/bufreader/BufReader#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/buffered/bufreader/impl#[`BufReader<R>`]new().(&mut rx); |
| 533 |
let mut buffer = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![0u8; 1024]; |
| 534 |
loop { |
| 535 |
if reader.readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/buffered/bufreader/impl#[`BufReader<R>`][Read]read().(&mut buffer).is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().() { |
| 536 |
break; |
| 537 |
} |
| 538 |
} |
| 539 |
} |
| 540 |
|
| 541 |
// Now we should become writable |
| 542 |
while !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().dispatched { |
| 543 |
event_loop.dispatchrust-analyzer cargo calloop 0.10.5 loop_logic/impl#[`EventLoop<'l, Data>`]dispatch().(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, &mut dispatched).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 544 |
} |
| 545 |
} |
| 546 |
} |