Struct easyfibers::Fiber
[−]
[src]
pub struct Fiber<P, R> { /* fields omitted */ }
Available within the fiber execute function to configure fiber or create child fibers. Child fibers return results to parent fibers instead of poller on main stack.
Methods
impl<P, R> Fiber<P, R>
[src]
fn socket_timeout(&self, t: Option<Duration>)
How long to wait on socket operations before timing out. You probably want to set something.
fn resp_chunk(&self, chunk: R)
Return intermediate result. A fiber can stream responses to poller or to its parent fiber.
This function blocks fiber until response is received to poller or parent.
fn accept_tcp(&self) -> Result<(TcpStream, SocketAddr)>
Accept TCP socket. Works only on fibers from TcpListener.
fn tcp_tls_connect(&self, con: TlsConnector, domain: &str) -> Result<()>
Convert fiber from TcpStream created with TcpStream::connect to TlsStream.
fn tcp_tls_accept(&self, con: TlsAcceptor) -> Result<()>
Convert fiber from TcpStream created with TcpListener::accept to TlsStream.
fn new_tcp(&self, tcp: TcpStream, func: FiberFn<P, R>, param: P) -> Result<()>
Start fiber on TCP socket.
This function does not block and fiber gets executed on next poll(). There is no relationship between calling and created fiber.
fn new_listener(
&self,
tcp: TcpListener,
func: FiberFn<P, R>,
param: P
) -> Result<()>
&self,
tcp: TcpListener,
func: FiberFn<P, R>,
param: P
) -> Result<()>
Start fiber on TCP listener.
This function does not block and fiber gets executed on next poll(). There is no relationship between calling and created fiber.
fn new_udp(&self, udp: UdpSocket, func: FiberFn<P, R>, param: P) -> Result<()>
Start fiber on UDP socket.
This function does not block and fiber gets executed on next poll(). There is no relationship between calling and created fiber.
fn new_resolve_connect(
&self,
domain: &str,
st: SocketType,
port: u16,
timeout: Duration,
func: FiberFn<P, R>,
param: P
) -> Result<()>
&self,
domain: &str,
st: SocketType,
port: u16,
timeout: Duration,
func: FiberFn<P, R>,
param: P
) -> Result<()>
Resolve domain, connect and run fiber. In case domain resolve or connect fails, fiber will still be run but all socket operations will fail.
This function does not block, host lookup starts immediately. There is no relationship between calling and created fiber.
fn join_tcp(&self, tcp: TcpStream, func: FiberFn<P, R>, param: P) -> Result<()>
Start a child fiber with tcp socket.
This function does not block current fiber.
fn join_udp(&self, udp: UdpSocket, func: FiberFn<P, R>, param: P) -> Result<()>
Start a child fiber with an udp socket.
This function does not block current fiber.
fn join_resolve_connect(
&self,
domain: &str,
st: SocketType,
port: u16,
timeout: Duration,
func: FiberFn<P, R>,
param: P
) -> Result<()>
&self,
domain: &str,
st: SocketType,
port: u16,
timeout: Duration,
func: FiberFn<P, R>,
param: P
) -> Result<()>
Start a child fiber that resolves domain, connects and runs fiber. In case domain resolve or connect fails, fiber will still be run but all socket operations will fail.
This function does not block, host lookup starts immediately.
fn join_main(&self) -> R
Call main stack.
This function blocks until main stack produces response.
fn get_child(&self) -> Option<R>
Get result of child. If fiber has multiple children it will return first available result. Will block current fiber if nothing available immediately.
If none is returned all children have finished executing.
fn hibernate_for_read(&self) -> Result<()>
Remove stack from current fiber and reuse on other connections. Once socket becomes signalled for reads, resume from the start of FiberFn.
Trait Implementations
impl<P: PartialEq, R: PartialEq> PartialEq for Fiber<P, R>
[src]
fn eq(&self, __arg_0: &Fiber<P, R>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Fiber<P, R>) -> bool
This method tests for !=
.
impl<P: Debug, R: Debug> Debug for Fiber<P, R>
[src]
impl<P, R> Read for Fiber<P, R>
[src]
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
Read data from socket. If no data is available to read, fiber will be scheduled out for another one, until there is data available.
unsafe fn initializer(&self) -> Initializer
read_initializer
)Determines if this Read
er can work with buffers of uninitialized memory. Read more
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
1.0.0
Read all bytes until EOF in this source, placing them into buf
. Read more
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
1.0.0
Read all bytes until EOF in this source, placing them into buf
. Read more
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
1.6.0
Read the exact number of bytes required to fill buf
. Read more
fn by_ref(&mut self) -> &mut Self
1.0.0
Creates a "by reference" adaptor for this instance of Read
. Read more
fn bytes(self) -> Bytes<Self>
1.0.0
Transforms this Read
instance to an Iterator
over its bytes. Read more
fn chars(self) -> Chars<Self>
🔬 This is a nightly-only experimental API. (io
)
the semantics of a partial read/write of where errors happen is currently unclear and may change
Transforms this Read
instance to an Iterator
over char
s. Read more
fn chain<R>(self, next: R) -> Chain<Self, R> where
R: Read,
1.0.0
R: Read,
Creates an adaptor which will chain this stream with another. Read more
fn take(self, limit: u64) -> Take<Self>
1.0.0
Creates an adaptor which will read at most limit
bytes from it. Read more
impl<'a, P, R> Read for &'a Fiber<P, R>
[src]
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
Read data from socket. If no data is available to read, fiber will be scheduled out for another one, until there is data available.
unsafe fn initializer(&self) -> Initializer
read_initializer
)Determines if this Read
er can work with buffers of uninitialized memory. Read more
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
1.0.0
Read all bytes until EOF in this source, placing them into buf
. Read more
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
1.0.0
Read all bytes until EOF in this source, placing them into buf
. Read more
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
1.6.0
Read the exact number of bytes required to fill buf
. Read more
fn by_ref(&mut self) -> &mut Self
1.0.0
Creates a "by reference" adaptor for this instance of Read
. Read more
fn bytes(self) -> Bytes<Self>
1.0.0
Transforms this Read
instance to an Iterator
over its bytes. Read more
fn chars(self) -> Chars<Self>
🔬 This is a nightly-only experimental API. (io
)
the semantics of a partial read/write of where errors happen is currently unclear and may change
Transforms this Read
instance to an Iterator
over char
s. Read more
fn chain<R>(self, next: R) -> Chain<Self, R> where
R: Read,
1.0.0
R: Read,
Creates an adaptor which will chain this stream with another. Read more
fn take(self, limit: u64) -> Take<Self>
1.0.0
Creates an adaptor which will read at most limit
bytes from it. Read more
impl<P, R> Write for Fiber<P, R>
[src]
fn write(&mut self, buf: &[u8]) -> Result<usize>
Write data to socket. If data can not be written at this time, fiber will be scheduled out for another one until there is data available.
fn flush(&mut self) -> Result<()>
Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
1.0.0
Attempts to write an entire buffer into this write. Read more
fn write_fmt(&mut self, fmt: Arguments) -> Result<(), Error>
1.0.0
Writes a formatted string into this writer, returning any error encountered. Read more
fn by_ref(&mut self) -> &mut Self
1.0.0
Creates a "by reference" adaptor for this instance of Write
. Read more