Docs.rs
  • async-std-1.0.1
    • async-std 1.0.1
    • Docs.rs crate page
    • Apache-2.0/MIT
    • Links
    • Repository
    • crates.io
    • Source
    • Owners
    • skade
    • yoshuawuyts
    • Keruspe
    • joshtriplett
    • dignifiedquire
    • Dependencies
      • async-attributes ^1.1.0 normal
      • async-macros ^1.0.0 normal
      • async-task ^1.0.0 normal
      • broadcaster ^0.2.6 normal
      • crossbeam-channel ^0.3.9 normal
      • crossbeam-deque ^0.7.1 normal
      • crossbeam-utils ^0.6.6 normal
      • futures-core ^0.3.0 normal
      • futures-io ^0.3.0 normal
      • futures-timer ^1.0.2 normal
      • kv-log-macro ^1.0.4 normal
      • log ^0.4.8 normal
      • memchr ^2.2.1 normal
      • mio ^0.6.19 normal
      • mio-uds ^0.6.7 normal
      • num_cpus ^1.10.1 normal
      • once_cell ^1.2.0 normal
      • pin-project-lite ^0.1 normal
      • pin-utils ^0.1.0-alpha.4 normal
      • slab ^0.4.2 normal
      • femme ^1.2.0 dev
      • futures ^0.3.0 dev
      • rand ^0.7.2 dev
      • tempdir ^0.3.7 dev
    • Versions
  • Go to latest version
  • Platform
    • i686-apple-darwin
    • i686-unknown-linux-gnu
    • x86_64-apple-darwin
    • 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
☰
logo

Crate async_std

See all async_std's items

  • Modules
  • Macros

Crates

  • async_std
Change settings

[−][src]Crate async_std

[−] Expand description

Async version of the Rust standard library

async-std is a foundation of portable Rust software, a set of minimal and battle-tested shared abstractions for the broader Rust ecosystem. It offers std types, like Future and Stream, library-defined operations on language primitives, standard macros, I/O and multithreading, among many other things.

async-std is available from crates.io. Once included, async-std can be accessed in use statements through the path async_std, as in use async_std::future.

How to read this documentation

If you already know the name of what you are looking for, the fastest way to find it is to use the search bar at the top of the page.

Otherwise, you may want to jump to one of these useful sections:

  • async_std::* modules
  • Async macros
  • The Async Prelude
  • Cargo.toml feature flags
  • Examples

If this is your first time, the documentation for async-std is written to be casually perused. Clicking on interesting things should generally lead you to interesting places. Still, there are important bits you don't want to miss, so read on for a tour of the async-std and its documentation!

Once you are familiar with the contents of async-std you may begin to find the verbosity of the prose distracting. At this stage in your development you may want to press the [-] button near the top of the page to collapse it into a more skimmable view.

While you are looking at that [-] button also notice the [src] button. Rust's API documentation comes with the source code and you are encouraged to read it. The async-std source is generally high quality and a peek behind the curtains is often enlightening.

Modules in this crate are organized in the same way as in async-std, except blocking functions have been replaced with async functions and threads have been replaced with lightweight tasks.

You can find more information, reading materials, and other resources here:

  • The async-std website
  • The async-std book
  • GitHub repository
  • List of code examples
  • Discord chat

What is in the async-std documentation?

First, async-std is divided into a number of focused modules, all listed further down this page. These modules are the bedrock upon which async Rust is forged, and they have mighty names like async_std::os and async_std::task. Modules' documentation typically includes an overview of the module along with examples, and are a smart place to start familiarizing yourself with the library.

Second, async-std defines The Async Prelude, a small collection of items - mostly traits - that should be imported into every module of every async crate. The traits in the prelude are pervasive, making the prelude documentation a good entry point to learning about the library.

And finally, async-std exports a number of async macros, and lists them on this page.

Contributing changes to the documentation

Check out async-std's contribution guidelines here. The source for this documentation can be found on GitHub. To contribute changes, make sure you read the guidelines first, then submit pull requests for your suggested changes.

Contributions are appreciated! If you see a part of the docs that can be improved, submit a PR, or chat with us first on Discord.

A tour of async-std

The rest of this crate documentation is dedicated to pointing out notable features of async-std.

Platform abstractions and I/O

Besides basic data types, async-std is largely concerned with abstracting over differences in common platforms, most notably Windows and Unix derivatives.

Common types of I/O, including files, TCP, UDP, are defined in the io, fs, and net modules.

The task module contains async-std's task abstractions. sync contains further primitive shared memory types, including channel, which contains the channel types for message passing.

Timeouts, intervals, and delays

async-std provides several methods to manipulate time:

  • task::sleep to wait for a duration to pass without blocking.
  • stream::interval for emitting an event at a set interval.
  • future::timeout to time-out futures if they don't resolve within a set interval.

Examples

Spawn a task and block the current thread on its result:

use async_std::task;

fn main() {
    task::block_on(async {
        println!("Hello, world!");
    })
}

Features

Items marked with unstable are available only when the unstable Cargo feature is enabled:

[dependencies.async-std]
version = "1.0.0"
features = ["unstable"]

Items marked with attributes are available only when the attributes Cargo feature is enabled:

[dependencies.async-std]
version = "1.0.0"
features = ["attributes"]

Additionally it's possible to only use the core traits and combinators by only enabling the std Cargo feature:

[dependencies.async-std]
version = "1.0.0"
default-features = false
features = ["std"]

Modules

fs

Filesystem manipulation operations.

future

Asynchronous values.

io

Traits, helpers, and type definitions for core I/O functionality.

net

Networking primitives for TCP/UDP communication.

os

OS-specific extensions.

path

Cross-platform path manipulation.

pinunstable

Types that pin data to its location in memory.

prelude

The async prelude.

processunstable

A module for working with processes.

stream

Composable asynchronous iteration.

sync

Synchronization primitives.

task

Types and traits for working with asynchronous tasks.

Macros

eprintunstable

Prints to the standard error.

eprintlnunstable

Prints to the standard error, with a newline.

printunstable

Prints to the standard output.

printlnunstable

Prints to the standard output, with a newline.

task_local

Declares task-local values.

writeunstable

Writes formatted data into a buffer.

writelnunstable

Write formatted data into a buffer, with a newline appended.

Attribute Macros

mainattributes

Enables an async main function.

testattributes

Enables an async test function.

Results for bool

In Names
(5)
In Parameters
(12)
In Return Types
(168)
async_std::net::Shutdown::BothBoth the reading and the writing portions of the… 
async_std::task::PollIndicates whether a value is available or if the current… 
async_std::future::Future::pollAttempt to resolve the future to a final value,… 
async_std::pin::Pin::poll 
async_std::task::JoinHandle::poll 
async_std::fs::OpenOptions::readConfigures the option for read mode. 
async_std::fs::OpenOptions::writeConfigures the option for write mode. 
async_std::fs::OpenOptions::appendConfigures the option for append mode. 
async_std::fs::OpenOptions::createConfigures the option for creating a new file if it… 
async_std::fs::OpenOptions::truncateConfigures the option for truncating the previous file. 
async_std::fs::DirBuilder::recursiveSets the option for recursive mode. 
async_std::fs::OpenOptions::create_newConfigures the option for creating a new file or failing… 
async_std::net::TcpStream::set_nodelaySets the value of the `TCP_NODELAY` option on this socket. 
async_std::fs::Permissions::set_readonlyConfigures the read-only flag. 
async_std::net::UdpSocket::set_broadcastSets the value of the `SO_BROADCAST` option for this socket. 
async_std::net::UdpSocket::set_multicast_loop_v4Sets the value of the `IP_MULTICAST_LOOP` option for this… 
async_std::net::UdpSocket::set_multicast_loop_v6Sets the value of the `IPV6_MULTICAST_LOOP` option for… 
async_std::stream::Stream::eqDetermines if the elements of this `Stream` are… 
async_std::sync::Arc::eqEquality for two `Arc`s. 
async_std::fs::FileType::eq 
async_std::fs::Permissions::eq 
async_std::future::TimeoutError::eq 
async_std::io::SeekFrom::eq 
async_std::io::ErrorKind::eq 
async_std::net::AddrParseError::eq 
async_std::net::Ipv4Addr::eq 
async_std::net::Ipv6Addr::eq 
async_std::net::SocketAddrV6::eq 
async_std::net::SocketAddr::eq 
async_std::net::IpAddr::eq 
async_std::net::SocketAddrV4::eq 
async_std::net::Shutdown::eq 
async_std::path::StripPrefixError::eq 
async_std::path::PrefixComponent::eq 
async_std::path::Component::eq 
async_std::path::Prefix::eq 
async_std::path::Components::eq 
async_std::path::Path::eq 
async_std::path::PathBuf::eq 
async_std::pin::Pin::eq 
async_std::process::Output::eq 
async_std::process::ExitStatus::eq 
async_std::stream::TimeoutError::eq 
async_std::task::Poll::eq 
async_std::task::TaskId::eq 
async_std::task::AccessError::eq 
async_std::stream::Stream::geDetermines if the elements of this `Stream` are… 
async_std::sync::Arc::ge'Greater than or equal to' comparison for two `Arc`s. 
async_std::net::IpAddr::ge 
async_std::path::Component::ge 
async_std::path::Prefix::ge 
async_std::path::Components::ge 
async_std::path::Path::ge 
async_std::path::PathBuf::ge 
async_std::pin::Pin::ge 
async_std::task::Poll::ge 
async_std::stream::Stream::gtDetermines if the elements of this `Stream` are… 
async_std::sync::Arc::gtGreater-than comparison for two `Arc`s. 
async_std::net::IpAddr::gt 
async_std::path::Component::gt 
async_std::path::Prefix::gt 
async_std::path::Components::gt 
async_std::path::Path::gt 
async_std::path::PathBuf::gt 
async_std::pin::Pin::gt 
async_std::task::Poll::gt 
async_std::stream::Stream::leDetermines if the elements of this `Stream` are… 
async_std::sync::Arc::le'Less than or equal to' comparison for two `Arc`s. 
async_std::net::IpAddr::le 
async_std::path::Component::le 
async_std::path::Prefix::le 
async_std::path::Components::le 
async_std::path::Path::le 
async_std::path::PathBuf::le 
async_std::pin::Pin::le 
async_std::task::Poll::le 
async_std::stream::Stream::ltDetermines if the elements of this `Stream` are… 
async_std::sync::Arc::ltLess-than comparison for two `Arc`s. 
async_std::net::IpAddr::lt 
async_std::path::Component::lt 
async_std::path::Prefix::lt 
async_std::path::Components::lt 
async_std::path::Path::lt 
async_std::path::PathBuf::lt 
async_std::pin::Pin::lt 
async_std::task::Poll::lt 
async_std::stream::Stream::neDetermines if the elements of this `Stream` are… 
async_std::sync::Arc::neInequality for two `Arc`s. 
async_std::fs::FileType::ne 
async_std::fs::Permissions::ne 
async_std::future::TimeoutError::ne 
async_std::io::SeekFrom::ne 
async_std::net::AddrParseError::ne 
async_std::net::SocketAddr::ne 
async_std::net::IpAddr::ne 
async_std::path::StripPrefixError::ne 
async_std::path::Component::ne 
async_std::path::Prefix::ne 
async_std::path::Components::ne 
async_std::path::Path::ne 
async_std::path::PathBuf::ne 
async_std::pin::Pin::ne 
async_std::process::Output::ne 
async_std::process::ExitStatus::ne 
async_std::stream::TimeoutError::ne 
async_std::task::Poll::ne 
async_std::task::TaskId::ne 
async_std::task::AccessError::ne 
async_std::stream::Stream::allTests if every element of the stream matches a predicate. 
async_std::stream::Stream::anyTests if any element of the stream matches a predicate. 
async_std::path::PathBuf::popTruncates `self` to [`self.parent`]. 
async_std::fs::FileType::is_dirReturns `true` if this file type represents a regular… 
async_std::fs::Metadata::is_dirReturns `true` if this metadata is for a regular directory. 
async_std::sync::Arc::ptr_eqReturns `true` if the two `Arc`s point to the same… 
async_std::sync::Weak::ptr_eqReturns `true` if the two `Weak`s point to the same… 
async_std::fs::FileType::is_fileReturns `true` if this file type represents a regular file. 
async_std::fs::Metadata::is_fileReturns `true` if this metadata is for a regular file. 
async_std::sync::Sender::is_fullReturns `true` if the channel is full. 
async_std::sync::Receiver::is_fullReturns `true` if the channel is full. 
async_std::net::IpAddr::is_ipv4Returns [`true`] if this address is an [IPv4 address], and… 
async_std::net::SocketAddr::is_ipv4Returns [`true`] if the [IP address] in this `SocketAddr`… 
async_std::net::IpAddr::is_ipv6Returns [`true`] if this address is an [IPv6 address], and… 
async_std::net::SocketAddr::is_ipv6Returns [`true`] if the [IP address] in this `SocketAddr`… 
async_std::net::TcpStream::nodelayGets the value of the `TCP_NODELAY` option on this socket. 
async_std::process::ExitStatus::successWas termination successful? Signal termination is not… 
async_std::path::Path::has_rootReturns `true` if the `Path` has a root. 
async_std::sync::Sender::is_emptyReturns `true` if the channel is empty. 
async_std::sync::Receiver::is_emptyReturns `true` if the channel is empty. 
async_std::task::Poll::is_readyReturns `true` if this is `Poll::Ready` 
async_std::fs::Permissions::readonlyReturns the read-only flag. 
async_std::net::UdpSocket::broadcastGets the value of the `SO_BROADCAST` option for this socket. 
async_std::path::Path::ends_withDetermines whether `child` is a suffix of `self`. 
async_std::net::IpAddr::is_globalReturns [`true`] if the address appears to be globally… 
async_std::net::Ipv4Addr::is_globalReturns [`true`] if the address appears to be globally… 
async_std::net::Ipv6Addr::is_globalReturns [`true`] if the address appears to be globally… 
async_std::sync::BarrierWaitResult::is_leaderReturns `true` if this task from [`wait`] is the "leader… 
async_std::net::Ipv4Addr::is_sharedReturns [`true`] if this address is part of the Shared… 
async_std::task::Waker::will_wakeReturns `true` if this `Waker` and another `Waker` have… 
async_std::task::Poll::is_pendingReturns `true` if this is `Poll::Pending` 
async_std::net::Ipv4Addr::is_privateReturns [`true`] if this is a private address. 
async_std::fs::FileType::is_symlinkReturns `true` if this file type represents a symbolic link. 
async_std::os::unix::net::SocketAddr::is_unnamedReturns `true` if the address is unnamed. 
async_std::path::Path::is_absoluteReturns `true` if the `Path` is absolute, i.e. if it is… 
async_std::net::IpAddr::is_loopbackReturns [`true`] if this is a loopback address. 
async_std::net::Ipv4Addr::is_loopbackReturns [`true`] if this is a loopback address… 
async_std::net::Ipv6Addr::is_loopbackReturns [`true`] if this is a loopback address (::1). 
async_std::path::Path::is_relativeReturns `true` if the `Path` is relative, i.e. not absolute. 
async_std::net::Ipv4Addr::is_reservedReturns [`true`] if this address is reserved by IANA for… 
async_std::path::Prefix::is_verbatimDetermines if the prefix is verbatim, i.e., begins with… 
async_std::path::Path::starts_withDetermines whether `base` is a prefix of `self`. 
async_std::net::Ipv4Addr::is_broadcastReturns [`true`] if this is a broadcast address… 
async_std::net::IpAddr::is_multicastReturns [`true`] if this is a multicast address. 
async_std::net::Ipv4Addr::is_multicastReturns [`true`] if this is a multicast address… 
async_std::net::Ipv6Addr::is_multicastReturns [`true`] if this is a multicast address (ff00::/8). 
async_std::path::is_separatorDetermines whether the character is one of the permitted… 
async_std::net::Ipv4Addr::is_link_localReturns [`true`] if the address is link-local… 
async_std::pin::Pin::is_terminated 
async_std::path::PathBuf::set_extensionUpdates [`self.extension`] to `extension`. 
async_std::net::IpAddr::is_unspecifiedReturns [`true`] for the special 'unspecified' address. 
async_std::net::Ipv4Addr::is_unspecifiedReturns [`true`] for the special 'unspecified' address… 
async_std::net::Ipv6Addr::is_unspecifiedReturns [`true`] for the special 'unspecified' address (::). 
async_std::net::Ipv4Addr::is_benchmarkingReturns [`true`] if this address part of the… 
async_std::net::Ipv6Addr::is_unique_localReturns [`true`] if this is a unique local address… 
async_std::net::IpAddr::is_documentationReturns [`true`] if this address is in a range designated… 
async_std::net::Ipv4Addr::is_documentationReturns [`true`] if this address is in a range designated… 
async_std::net::Ipv6Addr::is_documentationReturns [`true`] if this is an address reserved for… 
async_std::net::Ipv6Addr::is_unicast_globalReturns [`true`] if the address is a globally routable… 
async_std::net::UdpSocket::multicast_loop_v4Gets the value of the `IP_MULTICAST_LOOP` option for this… 
async_std::net::UdpSocket::multicast_loop_v6Gets the value of the `IPV6_MULTICAST_LOOP` option for… 
async_std::net::Ipv6Addr::is_unicast_link_localReturns [`true`] if the address is a unicast link-local… 
async_std::net::Ipv6Addr::is_unicast_site_localReturns [`true`] if this is a deprecated unicast… 
async_std::net::Ipv4Addr::is_ietf_protocol_assignmentReturns [`true`] if this address is part of… 
async_std::net::Ipv6Addr::is_unicast_link_local_strictReturns [`true`] if the address is a unicast link-local… 
async_std::stream::Sum::sumMethod which takes a stream and generates `Self` from the… 
async_std::prelude::StreamExt::sumSums the elements of a stream. 
async_std::pin::Pin::fromConverts a `Box<T>` into a `Pin<Box<T>>` 
async_std::stream::Extend::extendExtends a collection with the contents of a stream. 
async_std::path::PathBuf::extend 
async_std::prelude::StreamExt::collectTransforms a stream into a collection. 
async_std::stream::Product::productMethod which takes a stream and generates `Self` from the… 
async_std::prelude::StreamExt::productMultiplies all elements of the stream. 
async_std::io::Error::into_innerConsumes the `Error`, returning its inner error (if any). 
async_std::stream::FromStream::from_streamCreates a value from a stream. 
async_std::path::PathBuf::from_stream 
async_std::sync::Arc::from_stream