Crate asio [−] [src]
The asio is Asynchronous Input/Output library.
Usage
This crate is on github and can be used by adding asio
to the dependencies in your project's Cargo.toml.
[dependencies]
rust_asio = "*"
And this in your crate root:
extern crate asio;
For example, Connection with TCP socket code:
use std::io; use asio::*; use asio::ip::*; struct TcpClient(TcpSocket); impl TcpClient { fn start(io: &IoService) { let soc = Strand::new(io, TcpClient(TcpSocket::new(Tcp::v4()).unwrap())); let ep = TcpEndpoint::new((IpAddrV4::new(192,168,0,1), 12345)); TcpSocket::async_connect(|soc| &soc.0, &ep, Self::on_connect, &soc); } fn on_connect(soc: Strand<Self>, res: io::Result<()>) { match res { Ok(_) => println!("connected."), Err(err) => println!("{:?}", err), } } } fn main() { //let io = IoService::new(); //TcpClient::start(&io); //io.run(); }
Modules
ip | |
local | |
socket_base |
Structs
IoService |
The core I/O process. |
SteadyTimer | |
Strand |
Serialized object for an |
StreamBuf | |
SystemTimer |
Enums
Shutdown |
Possible values which can be passed to the shutdown method. |
Traits
Cancel | |
DgramSocket | |
Endpoint | |
GetSocketOption | |
IoControl | |
IoObject |
Traits to the associated with |
MatchCondition | |
NonBlocking | |
Protocol | |
RawSocket | |
ReadWrite | |
SendRecv | |
SendToRecvFrom | |
SetSocketOption | |
Socket | |
SocketConnector | |
SocketListener | |
StreamSocket | |
WaitTimer |
Functions
async_accept | |
async_connect | |
async_read_some | |
async_read_until | |
async_recv | |
async_recv_from | |
async_send | |
async_send_to | |
async_write_some | |
async_write_until | |
cancel | |
read_until | |
write_until |