Docs.rs
  • async-std-utp-0.1.1
    • async-std-utp 0.1.1
    • Docs.rs crate page
    • MIT/Apache-2.0
    • Links
    • Homepage
    • Documentation
    • Repository
    • crates.io
    • Source
    • Owners
    • bltavares
    • Dependencies
      • async-recursion ^0.3.2 normal
      • async-std ^1.9.0 normal
      • futures ^0.3.15 normal
      • log ^0.4.14 normal
      • num-traits ^0.2.14 normal
      • rand ^0.8.3 normal
      • async-std ^1.9.0 dev
      • env_logger ^0.8.3 dev
      • quickcheck ^1.0.3 dev
    • Versions
    • 100% of the crate is documented
  • Platform
    • i686-pc-windows-msvc
    • i686-unknown-linux-gnu
    • x86_64-apple-darwin
    • x86_64-pc-windows-msvc
    • x86_64-unknown-linux-gnu
  • Feature flags
  • docs.rs
    • About docs.rs
    • Privacy policy
  • Rust
    • Rust website
    • The Book
    • Standard Library API Reference
    • Rust by Example
    • The Cargo Guide
    • Clippy Documentation

Crate async_std_utp

async_std_utp0.1.1

  • All Items

Sections

  • Installation
  • Examples

Crate Items

  • Structs

Crates

  • async_std_utp

Crate async_std_utp

Source
Expand description

Implementation of the Micro Transport Protocol.

This library provides both a socket interface (UtpSocket) and a stream interface (UtpStream). I recommend that you use UtpStream, as it implements the Read and Write traits we all know (and love) from std::io, which makes it generally easier to work with than UtpSocket.

§Installation

Ensure your Cargo.toml contains:

[dependencies]
utp = "*"

§Examples


use async_std_utp::UtpStream;
use async_std::prelude::*;

    // Connect to an hypothetical local server running on port 8080
    let addr = "127.0.0.1:8080";
    let mut stream = UtpStream::connect(addr).await.expect("Error connecting to remote peer");

    // Send a string
    stream.write("Hi there!".as_bytes()).await.expect("Write failed");

    // Close the stream
    stream.close().await.expect("Error closing connection");

Note that you can easily convert a socket to a stream using the Into trait, like so:

use async_std_utp::{UtpStream, UtpSocket};
let socket = UtpSocket::bind("0.0.0.0:0").await.expect("Error binding socket");
let stream: UtpStream = socket.into();

Structs§

UtpListener
A structure representing a socket server.
UtpSocket
A structure that represents a uTP (Micro Transport Protocol) connection between a local socket and a remote socket.
UtpStream
A structure that represents a uTP (Micro Transport Protocol) stream between a local socket and a remote socket.

Results

Settings
Help

Query parser error: "Unexpected - (did you mean ->?)".