zoukankan      html  css  js  c++  java
  • tokio 1.4 API 汇总

    https://docs.rs/tokio/1.4.0/tokio/index.html

    Modules

    fsfsAsynchronous file and standard stream adaptation.
    io Traits, helpers, and type definitions for asynchronous I/O functionality.
    net TCP/UDP/Unix bindings for tokio.
    process processAn implementation of asynchronous process management for Tokio.
    runtime rtThe Tokio runtime.
    signal signalAsynchronous signal handling for Tokio
    stream Due to the Stream trait’s inclusion in std landing later than Tokio’s 1.0 release, most of the Tokio stream utilities have been moved into the tokio-stream crate.try_join
    sync syncSynchronization primitives for use in asynchronous contexts.
    tokio::task Asynchronous green-threads.
    tokio::time timeUtilities for tracking time.

     

    tokio::fs

     Structs
    DirBuilder A builder for creating directories in various manners.
    DirEntry Entries returned by the ReadDir stream.
    File A reference to an open file on the filesystem.
    OpenOptions Options and flags which can be used to configure how a file is opened.
    ReadDir Read the the entries in a directory.
     Functions
    canonicalize Returns the canonical, absolute form of a path with all intermediate components normalized and symbolic links resolved.
    copy Copies the contents of one file to another. This function will also copy the permission bits of the original file to the destination file. This function will overwrite the contents of to.
    create_dir Creates a new, empty directory at the provided path
    create_dir_all Recursively creates a directory and all of its parent components if they are missing.
    hard_link Creates a new hard link on the filesystem.
    metadata Given a path, queries the file system to get information about a file, directory, etc.
    read Reads the entire contents of a file into a bytes vector.
    read_dir Returns a stream over the entries within a directory.
    read_link Reads a symbolic link, returning the file that the link points to.
    read_to_string Creates a future which will open a file for reading and read the entire contents into a string and return said string.
    remove_dir Removes an existing, empty directory.
    remove_dir_all Removes a directory at this path, after removing all its contents. Use carefully!
    remove_file Removes a file from the filesystem.
    rename Renames a file or directory to a new name, replacing the original file if to already exists.
    set_permissions Changes the permissions found on a file or a directory.
    symlink Creates a new symbolic link on the filesystem.
    symlink_metadata Queries the file system metadata for a path.
    write Creates a future that will open a file for writing and write the entire contents of contents to it.

     

    tokio::io

    Re-exports
    pub use std::io::Error;
    pub use std::io::ErrorKind;
    pub use std::io::Result;
    pub use std::io::SeekFrom;
     Modules
    unix netAsynchronous IO structures specific to Unix-like operating systems.
     Structs
    BufReader io-utilThe BufReader struct adds buffering to any reader.
    BufStream io-utilWraps a type that is AsyncWrite and AsyncRead, and buffers its input and output.
    BufWriter io-utilWraps a writer and buffers its output.
    DuplexStream A bidirectional pipe to read and write bytes in memory.
    Empty io-utilAn async reader which is always at EOF.
    Interest netReadiness event interest
    Lines io-utilRead lines from an AsyncBufRead.
    ReadBuf A wrapper around a byte buffer that is incrementally filled and initialized.
    ReadHalf io-utilThe readable half of a value returned from split.
    Ready netDescribes the readiness state of an I/O resources.
    Repeat io-utilAn async reader which yields one byte over and over and over and over and over and…
    Sink io-utilAn async writer which will move data into the void.
    Split io-utilSplitter for the split method.
    Stderr io-stdA handle to the standard error stream of a process.
    Stdin io-stdA handle to the standard input stream of a process.
    Stdout io-stdA handle to the standard output stream of a process.
    Take io-utilStream for the take method.
    WriteHalf io-utilThe writable half of a value returned from split.
     Traits
    AsyncBufRead Reads bytes asynchronously.
    AsyncBufReadExt io-utilAn extension trait which adds utility methods to AsyncBufRead types.
    AsyncRead Reads bytes from a source.
    AsyncReadExt io-utilReads bytes from a source.
    AsyncSeek Seek bytes asynchronously.
    AsyncSeekExt io-utilAn extension trait that adds utility methods to AsyncSeek types.
    AsyncWrite Writes bytes asynchronously.
    AsyncWriteExt io-utilWrites bytes to a sink.
     Functions
    copy io-utilAsynchronously copies the entire contents of a reader into a writer.
    copy_buf io-utilAsynchronously copies the entire contents of a reader into a writer.
    duplex Create a new pair of DuplexStreams that act like a pair of connected sockets.
    empty io-utilCreates a new empty async reader.
    repeat io-utilCreates an instance of an async reader that infinitely repeats one byte.
    sink io-utilCreates an instance of an async writer which will successfully consume all data.
    split io-utilSplits a single value implementing AsyncRead + AsyncWrite into separate AsyncRead and AsyncWrite handles.
    stderr io-stdConstructs a new handle to the standard error of the current process.
    stdin io-stdConstructs a new handle to the standard input of the current process.
    stdout io-stdConstructs a new handle to the standard output of the current process.

    tokio::net

     Modules
    tcp netTCP utility types
    unix netUnix domain socket utility types
    TcpListenernetA TCP socket server, listening for connections.
    TcpSocket netA TCP socket that has not yet been converted to a TcpStream or TcpListener.
    TcpStream netA TCP stream between a local and a remote socket.
    UdpSocket netA UDP socket
    UnixDatagram netAn I/O object representing a Unix datagram socket.
    UnixListener netA Unix socket which can accept connections from other Unix sockets.
    UnixStream netA structure representing a connected Unix socket.
     Traits
    ToSocketAddrs Converts or resolves without blocking to one or more SocketAddr values.
     Functions
    lookup_host netPerforms a DNS resolution.

    tokio::process

     Structs
    Child Representation of a child process spawned onto an event loop.
    ChildStderr The standard error stream for spawned children.
    ChildStdin The standard input stream for spawned children.
    ChildStdout The standard output stream for spawned children.
    Command This structure mimics the API of std::process::Command found in the standard library, but replaces functions that create a process with an asynchronous variant. The main provided asynchronous functions are spawn, status, and output.

    tokio::runtime

     Structs
    Builder Builds Tokio Runtime with custom configuration values.
    EnterGuard Runtime context guard.
    Handle Handle to the runtime.
    Runtime The Tokio runtime.

    tokio::signal

     Modules
    unix Unix-specific types for signal handling.
      Functions
    ctrl_c Completes when a “ctrl-c” notification is sent to the process.

    tokio::stream

    tokio::sync

     Modules
    broadcast A multi-producer, multi-consumer broadcast queue. Each sent value is seen by all consumers.
    mpsc A multi-producer, single-consumer queue for sending values between asynchronous tasks.
    oneshot 单触发通道用于在异步任务之间发送单个消息。 通道函数用于创建构成通道的“发送方”和“接收方”句柄对。
    watch 单生产者,多消费者通道,仅保留“最后”发送的值。 retains the last sent value.
     Structs
    AcquireError Error returned from the Semaphore::acquire function.
    Barrier A barrier enables multiple threads to synchronize the beginning of some computation.
    BarrierWaitResult A BarrierWaitResult is returned by wait when all threads in the Barrier have rendezvoused.
    Mutex An asynchronous Mutex-like type.
    MutexGuard A handle to a held Mutex.
    Notify Notify a single task to wake up.
    OwnedMutexGuard An owned handle to a held Mutex.
    OwnedSemaphorePermit An owned permit from the semaphore.
    RwLock An asynchronous reader-writer lock.
    RwLockMappedWriteGuard RAII structure used to release the exclusive write access of a lock when dropped.
    RwLockReadGuard RAII structure used to release the shared read access of a lock when dropped.
    RwLockWriteGuard RAII structure used to release the exclusive write access of a lock when dropped.
    Semaphore Counting semaphore performing asynchronous permit acquisition.
    SemaphorePermit A permit from the semaphore.
    TryLockError Error returned from the Mutex::try_lock, RwLock::try_read and RwLock::try_write functions.
     Enums
    TryAcquireError Error returned from the Semaphore::try_acquire function.

    tokio::task

     Structs
    JoinError rtTask failed to execute to completion.
    JoinHandle rtAn owned permission to join on a task (await its termination).
    LocalKey rt A key for task-local data.
    LocalSet rt A set of tasks which are executed on the same thread.
    Unconstrained Future for the unconstrained method.
     Functions
    block_in_place rt-multi-threadRuns the provided blocking function on the current thread without blocking the executor.
    spawn rtSpawns a new asynchronous task, returning a JoinHandle for it.
    spawn_blocking rtRuns the provided closure on a thread where blocking is acceptable.
    spawn_local rtSpawns a !Send future on the local task set.
    unconstrained Turn off cooperative scheduling for a future. The future will never be forced to yield by Tokio. Using this exposes your service to starvation if the unconstrained future never yields otherwise.
    yield_now rtYields execution back to the Tokio runtime.

    tokio::time

    Durationpub use std::time::Duration;
       
      Modules
    error Time error types.
     struct
    Instant A measurement of a monotonically nondecreasing clock. Opaque and useful only with Duration.
    Interval Interval returned by interval and interval_at.
    Sleep Future returned by sleep and sleep_until.
    Timeout Future returned by timeout and timeout_at.
     Function
    advance test-utilAdvance time
    interval Creates new Interval that yields with interval of duration. The first tick completes immediately.
    interval_at Creates new Interval that yields with interval of period with the first tick completing at start.
    pause test-utilPause time
    resume test-utilResume time
    sleep Waits until duration has elapsed.
    sleep_until Waits until deadline is reached.
    timeout Require a Future to complete before the specified duration has elapsed.
    timeout_at Require a Future to complete before the specified instant in time.
  • 相关阅读:
    【嵌入式硬件Esp32】Ubuntu18.04 更换阿里云软件源
    【嵌入式硬件Esp32】Ubuntu 1804下ESP32交叉编译环境搭建
    【嵌入式硬件Esp32】Eclipse c++切换回英文方法
    Ant Design使用问题记录
    C#调用python脚本
    C# 6新特性简单总结
    ASP.NET动态网站制作(30)-- WEBService
    ASP.NET动态网站制作(29)-- 正则
    ASP.NET动态网站制作(28)-- 三层框架(2)
    ASP.NET动态网站制作(27)-- 三层框架(1)
  • 原文地址:https://www.cnblogs.com/htsky/p/14608928.html
Copyright © 2011-2022 走看看