repo
stringclasses
7 values
lang
stringclasses
2 values
aspect
stringclasses
7 values
file
stringlengths
5
48
content
stringlengths
283
144k
tokio
rust
async_runtime
cfg.rs
macro_rules! cfg_codec { ($($item:item)*) => { $( #[cfg(feature = "codec")] #[cfg_attr(docsrs, doc(cfg(feature = "codec")))] $item )* } } macro_rules! cfg_compat { ($($item:item)*) => { $( #[cfg(feature = "compat")] #[cfg_a...
tokio
rust
async_runtime
either.rs
use futures_core::stream::FusedStream; use std::{ future::Future, io::SeekFrom, pin::Pin, task::{Context, Poll}, }; use tokio::io::{AsyncBufRead, AsyncRead, AsyncSeek, AsyncWrite, ReadBuf, Result}; /// Combines two different futures, streams, or sinks having the same associated types into a single type...
tokio
rust
async_runtime
future.rs
mod with_cancellation_token; use with_cancellation_token::{WithCancellationTokenFuture, WithCancellationTokenFutureOwned}; use std::future::Future; use crate::sync::CancellationToken; /// A trait which contains a variety of convenient adapters and utilities for `Future`s. pub trait FutureExt: Future { cfg_time! ...
tokio
rust
async_runtime
context.rs
use pin_project_lite::pin_project; use std::{ future::Future, pin::Pin, task::{Context, Poll}, }; use tokio::runtime::{Handle, Runtime}; pin_project! { /// `TokioContext` allows running futures that must be inside Tokio's /// context on a non-Tokio runtime. /// /// It contains a [`Handle`] ...
tokio
rust
async_runtime
mod.rs
#![cfg(not(loom))] use crate::either::Either; use std::future::Future; use std::io::Result; use std::pin::Pin; use std::task::{Context, Poll}; #[cfg(unix)] pub mod unix; /// A trait for a listener: `TcpListener` and `UnixListener`. pub trait Listener { /// The stream's type of this listener. type Io: tokio:...
tokio
rust
async_runtime
mod.rs
use super::Listener; use std::io::Result; use std::task::{Context, Poll}; impl Listener for tokio::net::UnixListener { type Io = tokio::net::UnixStream; type Addr = tokio::net::unix::SocketAddr; fn poll_accept(&mut self, cx: &mut Context<'_>) -> Poll<Result<(Self::Io, Self::Addr)>> { Self::poll_ac...
tokio
rust
async_runtime
mod.rs
mod maybe_dangling; #[cfg(feature = "codec")] pub(crate) mod memchr; #[cfg(any(feature = "io", feature = "codec"))] mod poll_buf; pub(crate) use maybe_dangling::MaybeDangling; #[cfg(any(feature = "io", feature = "codec"))] #[cfg_attr(not(feature = "io"), allow(unreachable_pub))] pub use poll_buf::{poll_read_buf, poll_...
tokio
rust
async_runtime
maybe_dangling.rs
use core::future::Future; use core::mem::MaybeUninit; use core::pin::Pin; use core::task::{Context, Poll}; /// A wrapper type that tells the compiler that the contents might not be valid. /// /// This is necessary mainly when `T` contains a reference. In that case, the /// compiler will sometimes assume that the refer...
tokio
rust
async_runtime
memchr.rs
#[cfg(not(all(unix, feature = "libc")))] fn memchr_inner(needle: u8, haystack: &[u8]) -> Option<usize> { haystack.iter().position(|val| needle == *val) } #[cfg(all(unix, feature = "libc"))] fn memchr_inner(needle: u8, haystack: &[u8]) -> Option<usize> { let start = haystack.as_ptr(); // SAFETY: `start` is...
tokio
rust
async_runtime
poll_buf.rs
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf}; use bytes::{Buf, BufMut}; use std::io::{self, IoSlice}; use std::pin::Pin; use std::task::{ready, Context, Poll}; /// Try to read data from an `AsyncRead` into an implementer of the [`BufMut`] trait. /// /// [`BufMut`]: bytes::BufMut /// /// # Example /// /// ``` /// u...
tokio
rust
async_runtime
frame.rs
use crate::codec::{Decoder, Encoder}; use futures_core::Stream; use tokio::{io::ReadBuf, net::UdpSocket}; use bytes::{BufMut, BytesMut}; use futures_sink::Sink; use std::io; use std::pin::Pin; use std::task::{ready, Context, Poll}; use std::{ borrow::Borrow, net::{Ipv4Addr, SocketAddr, SocketAddrV4}, }; /// ...
tokio
rust
async_runtime
lines_codec.rs
use crate::codec::decoder::Decoder; use crate::codec::encoder::Encoder; use bytes::{Buf, BufMut, BytesMut}; use std::{cmp, fmt, io, str}; /// A simple [`Decoder`] and [`Encoder`] implementation that splits up data into lines. /// /// This uses the `\n` character as the line ending on all platforms. /// /// [`Decoder`...
tokio
rust
async_runtime
encoder.rs
use bytes::BytesMut; use std::io; /// Trait of helper objects to write out messages as bytes, for use with /// [`FramedWrite`]. /// /// [`FramedWrite`]: crate::codec::FramedWrite pub trait Encoder<Item> { /// The type of encoding errors. /// /// [`FramedWrite`] requires `Encoder`s errors to implement `From...
tokio
rust
async_runtime
any_delimiter_codec.rs
use crate::codec::decoder::Decoder; use crate::codec::encoder::Encoder; use bytes::{Buf, BufMut, Bytes, BytesMut}; use std::{cmp, fmt, io, str}; const DEFAULT_SEEK_DELIMITERS: &[u8] = b",;\n\r"; const DEFAULT_SEQUENCE_WRITER: &[u8] = b","; /// A simple [`Decoder`] and [`Encoder`] implementation that splits up data in...
tokio
rust
async_runtime
length_delimited.rs
use crate::codec::{Decoder, Encoder, Framed, FramedRead, FramedWrite}; use tokio::io::{AsyncRead, AsyncWrite}; use bytes::{Buf, BufMut, Bytes, BytesMut}; use std::error::Error as StdError; use std::io::{self, Cursor}; use std::{cmp, fmt, mem}; /// Configure length delimited `LengthDelimitedCodec`s. /// /// `Builder`...
tokio
rust
async_runtime
framed_write.rs
use crate::codec::encoder::Encoder; use crate::codec::framed_impl::{FramedImpl, WriteFrame}; use futures_core::Stream; use tokio::io::AsyncWrite; use bytes::BytesMut; use futures_sink::Sink; use pin_project_lite::pin_project; use std::fmt; use std::io; use std::pin::Pin; use std::task::{Context, Poll}; use super::Fr...
tokio
rust
async_runtime
framed_impl.rs
use crate::codec::decoder::Decoder; use crate::codec::encoder::Encoder; use futures_core::Stream; use tokio::io::{AsyncRead, AsyncWrite}; use bytes::BytesMut; use futures_sink::Sink; use pin_project_lite::pin_project; use std::borrow::{Borrow, BorrowMut}; use std::io; use std::pin::Pin; use std::task::{ready, Context...
tokio
rust
async_runtime
decoder.rs
use crate::codec::Framed; use tokio::io::{AsyncRead, AsyncWrite}; use bytes::BytesMut; use std::io; /// Decoding of frames via buffers. /// /// This trait is used when constructing an instance of [`Framed`] or /// [`FramedRead`]. An implementation of `Decoder` takes a byte stream that has /// already been buffered i...
tokio
rust
async_runtime
framed_read.rs
use crate::codec::framed_impl::{FramedImpl, ReadFrame}; use crate::codec::Decoder; use futures_core::Stream; use tokio::io::AsyncRead; use bytes::BytesMut; use futures_sink::Sink; use pin_project_lite::pin_project; use std::fmt; use std::pin::Pin; use std::task::{Context, Poll}; use super::FramedParts; pin_project!...
tokio
rust
async_runtime
bytes_codec.rs
use crate::codec::decoder::Decoder; use crate::codec::encoder::Encoder; use bytes::{BufMut, Bytes, BytesMut}; use std::io; /// A simple [`Decoder`] and [`Encoder`] implementation that just ships bytes around. /// /// [`Decoder`]: crate::codec::Decoder /// [`Encoder`]: crate::codec::Encoder /// /// # Example /// /// T...
tokio
rust
async_runtime
mod.rs
mod bytes_codec; pub use self::bytes_codec::BytesCodec; mod decoder; pub use self::decoder::Decoder; mod encoder; pub use self::encoder::Encoder; mod framed_impl; #[allow(unused_imports)] pub(crate) use self::framed_impl::{FramedImpl, RWFrames, ReadFrame, WriteFrame}; mod framed; pub use self::framed::{Framed, Fram...
tokio
rust
async_runtime
framed.rs
use crate::codec::decoder::Decoder; use crate::codec::encoder::Encoder; use crate::codec::framed_impl::{FramedImpl, RWFrames, ReadFrame, WriteFrame}; use futures_core::Stream; use tokio::io::{AsyncRead, AsyncWrite}; use bytes::BytesMut; use futures_sink::Sink; use pin_project_lite::pin_project; use std::fmt; use std:...
tokio
rust
async_runtime
read_arc.rs
use std::io; use std::mem::MaybeUninit; use std::sync::Arc; use tokio::io::{AsyncRead, AsyncReadExt}; /// Read data from an `AsyncRead` into an `Arc`. /// /// This uses `Arc::new_uninit_slice` and reads into the resulting uninitialized `Arc`. /// /// Interrupted reads are retried. Other errors are returned immediately...
tokio
rust
async_runtime
write_all_vectored.rs
use tokio::io::AsyncWrite; use pin_project_lite::pin_project; use std::marker::PhantomPinned; use std::pin::Pin; use std::task::{ready, Context, Poll}; use std::{future::Future, io::IoSlice}; use std::{io, mem}; pin_project! { /// A future that writes all data from multiple buffers to a writer. #[derive(Debug...
tokio
rust
async_runtime
stream_reader.rs
use bytes::Buf; use futures_core::stream::Stream; use futures_sink::Sink; use std::io; use std::pin::Pin; use std::task::{Context, Poll}; use tokio::io::{AsyncBufRead, AsyncRead, ReadBuf}; /// Convert a [`Stream`] of byte chunks into an [`AsyncRead`]. /// /// This type performs the inverse operation of [`ReaderStream`...
tokio
rust
async_runtime
mod.rs
mod copy_to_bytes; mod inspect; mod read_buf; mod reader_stream; pub mod simplex; mod sink_writer; mod stream_reader; mod write_all_vectored; cfg_io_util! { mod read_arc; pub use self::read_arc::read_exact_arc; mod sync_bridge; pub use self::sync_bridge::SyncIoBridge; } pub use self::copy_to_bytes::C...
tokio
rust
async_runtime
sync_bridge.rs
use std::io::{BufRead, Read, Seek, Write}; use tokio::io::{ AsyncBufRead, AsyncBufReadExt, AsyncRead, AsyncReadExt, AsyncSeek, AsyncSeekExt, AsyncWrite, AsyncWriteExt, }; /// Use a [`tokio::io::AsyncRead`] synchronously as a [`std::io::Read`] or /// a [`tokio::io::AsyncWrite`] synchronously as a [`std::io::Wri...
tokio
rust
async_runtime
reader_stream.rs
use bytes::{Bytes, BytesMut}; use futures_core::stream::{FusedStream, Stream}; use pin_project_lite::pin_project; use std::pin::Pin; use std::task::{Context, Poll}; use tokio::io::AsyncRead; const DEFAULT_CAPACITY: usize = 4096; pin_project! { /// Convert an [`AsyncRead`] into a [`Stream`] of byte chunks. ///...
tokio
rust
async_runtime
copy_to_bytes.rs
use bytes::Bytes; use futures_core::stream::Stream; use futures_sink::Sink; use pin_project_lite::pin_project; use std::pin::Pin; use std::task::{Context, Poll}; pin_project! { /// A helper that wraps a [`Sink`]`<`[`Bytes`]`>` and converts it into a /// [`Sink`]`<&'a [u8]>` by copying each byte slice into an o...
tokio
rust
async_runtime
read_buf.rs
use bytes::BufMut; use std::future::poll_fn; use std::io; use std::pin::Pin; use tokio::io::AsyncRead; /// Read data from an `AsyncRead` into an implementer of the [`BufMut`] trait. /// /// [`BufMut`]: bytes::BufMut /// /// # Example /// /// ``` /// use bytes::{Bytes, BytesMut}; /// use tokio_stream as stream; /// use...
tokio
rust
async_runtime
simplex.rs
use crate::util::poll_proceed; use bytes::Buf; use bytes::BytesMut; use futures_core::ready; use std::io::Error as IoError; use std::io::ErrorKind as IoErrorKind; use std::io::IoSlice; use std::pin::Pin; use std::sync::{Arc, Mutex}; use std::task::{Context, Poll, Waker}; use tokio::io::{AsyncRead, AsyncWrite, ReadBuf}...
tokio
rust
async_runtime
sink_writer.rs
use futures_sink::Sink; use futures_core::stream::Stream; use pin_project_lite::pin_project; use std::io; use std::pin::Pin; use std::task::{ready, Context, Poll}; use tokio::io::{AsyncRead, AsyncWrite}; pin_project! { /// Convert a [`Sink`] of byte chunks into an [`AsyncWrite`]. /// /// Whenever you writ...
tokio
rust
async_runtime
delay_queue.rs
use crate::time::wheel::{self, Wheel}; use tokio::time::{sleep_until, Duration, Instant, Sleep}; use core::ops::{Index, IndexMut}; use slab::Slab; use std::cmp; use std::collections::HashMap; use std::convert::From; use std::fmt; use std::fmt::Debug; use std::future::Future; use std::marker::PhantomData; use std::pin...
tokio
rust
async_runtime
mod.rs
use std::time::Duration; mod wheel; pub mod delay_queue; // re-export `FutureExt` to avoid breaking change #[doc(inline)] pub use crate::future::FutureExt; #[doc(inline)] pub use delay_queue::DelayQueue; // ===== Internal utils ===== enum Round { Up, Down, } /// Convert a `Duration` to milliseconds, roun...
tokio
rust
async_runtime
mod.rs
mod level; pub(crate) use self::level::Expiration; use self::level::Level; mod stack; pub(crate) use self::stack::Stack; use std::borrow::Borrow; use std::fmt::Debug; /// Timing wheel implementation. /// /// This type provides the hashed timing wheel implementation that backs /// [`DelayQueue`]. /// /// The structur...
tokio
rust
async_runtime
stack.rs
use std::borrow::Borrow; use std::cmp::Eq; use std::hash::Hash; /// Abstracts the stack operations needed to track timeouts. pub(crate) trait Stack: Default { /// Type of the item stored in the stack type Owned: Borrow<Self::Borrowed>; /// Borrowed item type Borrowed: Eq + Hash; /// Item storage,...
tokio
rust
async_runtime
level.rs
use crate::time::wheel::Stack; use std::fmt; /// Wheel for a single level in the timer. This wheel contains 64 slots. pub(crate) struct Level<T> { level: usize, /// Bit field tracking which slots currently contain entries. /// /// Using a bit field to track slots that contain entries allows avoiding ...
tokio
rust
async_runtime
join_map.rs
use hashbrown::hash_table::Entry; use hashbrown::{HashMap, HashTable}; use std::borrow::Borrow; use std::collections::hash_map::RandomState; use std::fmt; use std::future::Future; use std::hash::{BuildHasher, Hash}; use std::marker::PhantomData; use tokio::runtime::Handle; use tokio::task::{AbortHandle, Id, JoinError, ...
tokio
rust
async_runtime
join_queue.rs
use super::AbortOnDropHandle; use std::{ collections::VecDeque, future::Future, pin::Pin, task::{Context, Poll}, }; use tokio::{ runtime::Handle, task::{AbortHandle, Id, JoinError, JoinHandle}, }; /// A FIFO queue for of tasks spawned on a Tokio runtime. /// /// A [`JoinQueue`] can be used to a...
tokio
rust
async_runtime
mod.rs
cfg_rt! { mod spawn_pinned; pub use spawn_pinned::LocalPoolHandle; pub mod task_tracker; #[doc(inline)] pub use task_tracker::TaskTracker; mod abort_on_drop; pub use abort_on_drop::{AbortOnDrop, AbortOnDropHandle}; mod join_queue; pub use join_queue::JoinQueue; } #[cfg(feature = ...
tokio
rust
async_runtime
task_tracker.rs
use pin_project_lite::pin_project; use std::fmt; use std::future::Future; use std::pin::Pin; use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::Arc; use std::task::{Context, Poll}; use tokio::sync::{futures::Notified, Notify}; #[cfg(feature = "rt")] use tokio::{ runtime::Handle, task::{JoinHandle, ...
tokio
rust
async_runtime
spawn_pinned.rs
use futures_util::future::{AbortHandle, Abortable}; use std::fmt; use std::fmt::{Debug, Formatter}; use std::future::Future; use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::Arc; use tokio::sync::mpsc::{unbounded_channel, UnboundedReceiver, UnboundedSender}; use tokio::sync::oneshot; use tokio::task::{spa...
tokio
rust
async_runtime
abort_on_drop.rs
use tokio::task::{AbortHandle, JoinError, JoinHandle}; use std::{ future::Future, mem::ManuallyDrop, pin::Pin, task::{Context, Poll}, }; /// A wrapper around a [`tokio::task::JoinHandle`], /// which [aborts] the task when it is dropped. /// /// [aborts]: tokio::task::JoinHandle::abort #[must_use = "Dr...
tokio
rust
async_runtime
poll_semaphore.rs
use futures_core::Stream; use std::fmt; use std::pin::Pin; use std::sync::Arc; use std::task::{ready, Context, Poll}; use tokio::sync::{AcquireError, OwnedSemaphorePermit, Semaphore, TryAcquireError}; use super::ReusableBoxFuture; /// A wrapper around [`Semaphore`] that provides a `poll_acquire` method. /// /// [`Sem...
tokio
rust
async_runtime
reusable_box.rs
use std::alloc::Layout; use std::fmt; use std::future::{self, Future}; use std::mem::{self, ManuallyDrop}; use std::pin::Pin; use std::ptr; use std::task::{Context, Poll}; /// A reusable `Pin<Box<dyn Future<Output = T> + Send + 'a>>`. /// /// This type lets you replace the future stored in the box without /// realloca...
tokio
rust
async_runtime
mpsc.rs
use futures_sink::Sink; use std::pin::Pin; use std::task::{Context, Poll}; use std::{fmt, mem}; use tokio::sync::mpsc::OwnedPermit; use tokio::sync::mpsc::Sender; use super::ReusableBoxFuture; /// Error returned by the `PollSender` when the channel is closed. #[derive(Debug)] pub struct PollSendError<T>(Option<T>); ...
tokio
rust
async_runtime
mod.rs
mod cancellation_token; pub use cancellation_token::{ guard::DropGuard, guard_ref::DropGuardRef, CancellationToken, WaitForCancellationFuture, WaitForCancellationFutureOwned, }; pub(crate) use cancellation_token::{RunUntilCancelledFuture, RunUntilCancelledFutureOwned}; mod mpsc; pub use mpsc::{PollSendError, P...
tokio
rust
async_runtime
cancellation_token.rs
pub(crate) mod guard; pub(crate) mod guard_ref; mod tree_node; use crate::loom::sync::Arc; use crate::util::MaybeDangling; use core::future::Future; use core::pin::Pin; use core::task::{Context, Poll}; use guard::DropGuard; use guard_ref::DropGuardRef; use pin_project_lite::pin_project; /// A token which can be used...
tokio
rust
async_runtime
loom_cancellation_token.rs
use crate::sync::CancellationToken; use loom::{future::block_on, thread}; use tokio_test::assert_ok; #[test] fn cancel_token() { loom::model(|| { let token = CancellationToken::new(); let token1 = token.clone(); let th1 = thread::spawn(move || { block_on(async { ...
tokio
rust
async_runtime
tree_node.rs
use crate::loom::sync::{Arc, Mutex, MutexGuard}; /// A node of the cancellation tree structure /// /// The actual data it holds is wrapped inside a mutex for synchronization. pub(crate) struct TreeNode { inner: Mutex<Inner>, waker: tokio::sync::Notify, } impl TreeNode { pub(crate) fn new() -> Self { ...
tokio
rust
async_runtime
guard.rs
use crate::sync::CancellationToken; /// A wrapper for cancellation token which automatically cancels /// it on drop. It is created using [`drop_guard`] method on the [`CancellationToken`]. /// /// [`drop_guard`]: CancellationToken::drop_guard #[derive(Debug)] pub struct DropGuard { pub(super) inner: Option<Cancell...
tokio
rust
async_runtime
guard_ref.rs
use crate::sync::CancellationToken; /// A wrapper for cancellation token which automatically cancels /// it on drop. It is created using [`drop_guard_ref`] method on the [`CancellationToken`]. /// /// This is a borrowed version of [`DropGuard`]. /// /// [`drop_guard_ref`]: CancellationToken::drop_guard_ref /// [`DropG...
tokio
rust
async_runtime
with_cancellation_token.rs
use std::{ future::Future, pin::Pin, task::{Context, Poll}, }; use pin_project_lite::pin_project; use crate::sync::{CancellationToken, RunUntilCancelledFuture, RunUntilCancelledFutureOwned}; pin_project! { /// A [`Future`] that is resolved once the corresponding [`CancellationToken`] /// is cance...
tokio
rust
async_runtime
io.rs
#![warn(rust_2018_idioms)] use std::io; use tokio::io::{AsyncReadExt, AsyncWriteExt}; use tokio::time::{Duration, Instant}; use tokio_test::io::Builder; #[tokio::test] async fn read() { let mut mock = Builder::new().read(b"hello ").read(b"world!").build(); let mut buf = [0; 256]; let n = mock.read(&mut ...
tokio
rust
async_runtime
block_on.rs
#![warn(rust_2018_idioms)] use tokio::time::{sleep_until, Duration, Instant}; use tokio_test::block_on; #[test] fn async_block() { assert_eq!(4, block_on(async { 4 })); } async fn five() -> u8 { 5 } #[test] fn async_fn() { assert_eq!(5, block_on(five())); } #[test] fn test_sleep() { let deadline = ...
tokio
rust
async_runtime
task.rs
use std::future::{pending, Future}; use std::pin::Pin; use std::task::{Context, Poll}; use tokio_stream::Stream; use tokio_test::task; /// A [`Stream`] that has a stub size hint. struct SizedStream; impl Stream for SizedStream { type Item = (); fn poll_next(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Pol...
tokio
rust
async_runtime
macros.rs
#![warn(rust_2018_idioms)] use std::task::Poll; use tokio_test::{ assert_pending, assert_ready, assert_ready_eq, assert_ready_err, assert_ready_ok, }; fn ready() -> Poll<()> { Poll::Ready(()) } fn ready_ok() -> Poll<Result<(), ()>> { Poll::Ready(Ok(())) } fn ready_err() -> Poll<Result<(), ()>> { Pol...
tokio
rust
async_runtime
io.rs
#![cfg(not(loom))] use tokio::io::{AsyncRead, AsyncWrite, ReadBuf}; use tokio::sync::mpsc; use tokio::time::{self, Duration, Instant, Sleep}; use tokio_stream::wrappers::UnboundedReceiverStream; use futures_core::Stream; use std::collections::VecDeque; use std::fmt; use std::future::Future; use std::pin::Pin; use st...
tokio
rust
async_runtime
lib.rs
#![warn( missing_debug_implementations, missing_docs, rust_2018_idioms, unreachable_pub )] #![doc(test( no_crate_inject, attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables)) ))] pub mod io; pub mod stream_mock; mod macros; pub mod task; /// Runs the provided future, blo...
tokio
rust
async_runtime
task.rs
use std::future::Future; use std::mem; use std::ops; use std::pin::Pin; use std::sync::{Arc, Condvar, Mutex}; use std::task::{Context, Poll, RawWaker, RawWakerVTable, Waker}; use tokio_stream::Stream; /// Spawn a future into a [`Spawn`] which wraps the future in a mocked executor. /// /// This can be used to spawn a ...
tokio
rust
async_runtime
macros.rs
/// Asserts a `Poll` is ready, returning the value. /// /// This will invoke `panic!` if the provided `Poll` does not evaluate to `Poll::Ready` at /// runtime. /// /// # Custom Messages /// /// This macro has a second form, where a custom panic message can be provided with or without /// arguments for formatting. /// /...
tokio
rust
async_runtime
macros.rs
#[test] #[cfg_attr(miri, ignore)] fn compile_fail_full() { let t = trybuild::TestCases::new(); #[cfg(feature = "full")] t.pass("tests/pass/forward_args_and_output.rs"); #[cfg(feature = "full")] t.pass("tests/pass/macros_main_return.rs"); #[cfg(feature = "full")] t.pass("tests/pass/macros_...
tokio
rust
async_runtime
macros_invalid_input.rs
#![deny(duplicate_macro_attributes)] use tests_build::tokio; #[tokio::main] fn main_is_not_async() {} #[tokio::main(foo)] async fn main_attr_has_unknown_args() {} #[tokio::main(threadpool::bar)] async fn main_attr_has_path_args() {} #[tokio::test] fn test_is_not_async() {} #[tokio::test(foo)] async fn test_attr_h...
tokio
rust
async_runtime
macros_type_mismatch.rs
use tests_build::tokio; #[tokio::main] async fn missing_semicolon_or_return_type() { Ok(()) } #[tokio::main] async fn missing_return_type() { return Ok(()); } #[tokio::main] async fn extra_semicolon() -> Result<(), ()> { help: try using a variant of the expected enum | 23 | Ok(Ok(());) ...
tokio
rust
async_runtime
macros_try_join.rs
use tests_build::tokio; #[tokio::main] async fn main() { // do not leak `RotatorSelect` let _ = tokio::try_join!(async { fn foo(_: impl RotatorSelect) {} }); // do not leak `std::task::Poll::Pending` let _ = tokio::try_join!(async { Pending }); // do not leak `std::task::Poll::Ready` ...
tokio
rust
async_runtime
macros_join.rs
use tests_build::tokio; #[tokio::main] async fn main() { // do not leak `RotatorSelect` let _ = tokio::join!(async { fn foo(_: impl RotatorSelect) {} }); // do not leak `std::task::Poll::Pending` let _ = tokio::join!(async { Pending }); // do not leak `std::task::Poll::Ready` let ...
tokio
rust
async_runtime
macros_select_cfg_invalid.rs
use tests_build::tokio; async fn cfg_attr_is_rejected() { tokio::select! { #[cfg_attr(all(), allow(unused))] _ = async {} => {}, } } async fn arbitrary_attribute_is_rejected() { tokio::select! { #[allow(unused)] _ = async {} => {}, } } async fn stacked_cfg_is_rejected(...
tokio
rust
async_runtime
macros_select_cfg.rs
use std::future; use tests_build::tokio; #[tokio::main(flavor = "current_thread")] async fn main() { // These names deliberately overlap with identifiers used by the macro's // expansion. They must continue to refer to the caller's bindings. let start = 1usize; let futures = 2usize; let disabled =...
tokio
rust
async_runtime
impl_trait.rs
use tests_build::tokio; #[tokio::main] async fn never() -> ! { loop {} } #[tokio::main] async fn impl_trait() -> impl Iterator<Item = impl core::fmt::Debug> { [()].into_iter() } #[tokio::main] async fn impl_trait2() -> Result<(), impl core::fmt::Debug> { Err(()) } fn main() { if impl_trait().count()...
tokio
rust
async_runtime
task_panic.rs
#![warn(rust_2018_idioms)] #![cfg(any( all(feature = "full", not(target_os = "wasi")), all(target_os = "emscripten", feature = "rt", feature = "macros") ))] #![cfg(panic = "unwind")] use futures::future; use std::error::Error; use tokio::runtime::Builder; use tokio::task; #[cfg(feature = "rt-multi-thread")] us...
tokio
rust
async_runtime
process_issue_8042.rs
#![warn(rust_2018_idioms)] #![cfg(all(feature = "full", unix, not(target_os = "wasi"), not(miri)))] use std::future::poll_fn; use std::os::fd::OwnedFd; use std::pin::Pin; use std::process::Stdio; use std::task::Poll; use std::time::Duration; use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt, ReadBuf};...
tokio
rust
async_runtime
io_chain.rs
#![warn(rust_2018_idioms)] #![cfg(any( feature = "full", all( target_os = "emscripten", feature = "rt", feature = "macros", feature = "io-util" ) ))] use tokio::io::AsyncReadExt; use tokio_test::assert_ok; #[tokio::test] async fn chain() { let mut buf = Vec::new(); ...
tokio
rust
async_runtime
task_local.rs
#![cfg(any( all(feature = "full", not(target_os = "wasi")), // Wasi doesn't support threads all(target_os = "emscripten", feature = "rt", feature = "macros") ))] use std::future::Future; use std::pin::Pin; use std::task::{Context, Poll}; use tokio::sync::oneshot; #[cfg_attr(not(target_family = "wasm"), tokio:...
tokio
rust
async_runtime
signal_usr1.rs
#![warn(rust_2018_idioms)] #![cfg(feature = "full")] #![cfg(unix)] #![cfg(not(miri))] // No `sigaction` in Miri. mod support { pub mod signal; } use support::signal::send_signal; use tokio::signal::unix::{signal, SignalKind}; use tokio_test::assert_ok; #[tokio::test] async fn signal_usr1() { let mut signal =...
tokio
rust
async_runtime
rt_shutdown_err.rs
#![warn(rust_2018_idioms)] #![cfg(any(feature = "full", all(target_os = "emscripten", feature = "rt")))] #![cfg(not(miri))] // No socket in miri. use std::io; #[cfg(not(target_family = "wasm"))] use tokio::net::TcpListener; use tokio::runtime::Builder; fn rt() -> tokio::runtime::Runtime { Builder::new_current_thr...
tokio
rust
async_runtime
fs_open_options.rs
#![warn(rust_2018_idioms)] #![cfg(all( any( feature = "full", all( target_os = "emscripten", feature = "fs", feature = "macros", feature = "rt", feature = "io-util" ) ), not(target_os = "wasi") ))] // WASI does not support a...
tokio
rust
async_runtime
io_panic.rs
#![warn(rust_2018_idioms)] #![cfg(any( all(feature = "full", not(target_os = "wasi")), // Wasi does not support panic recovery all(target_os = "emscripten", feature = "io-util") ))] #![cfg(panic = "unwind")] use std::task::{Context, Poll}; use std::{error::Error, pin::Pin}; use tokio::io::{self, duplex, simple...
tokio
rust
async_runtime
task_abort.rs
#![warn(rust_2018_idioms)] #![cfg(any( all(feature = "full", not(target_os = "wasi")), // Wasi doesn't support panic recovery all(target_os = "emscripten", feature = "rt", feature = "time") ))] #[cfg(not(target_family = "wasm"))] use std::sync::Arc; #[cfg(not(target_family = "wasm"))] use std::thread::sleep; #...
tokio
rust
async_runtime
uds_socket.rs
#![warn(rust_2018_idioms)] #![cfg(feature = "full")] #![cfg(unix)] use futures::future::try_join; use std::io; use tokio::{ io::{AsyncReadExt, AsyncWriteExt}, net::UnixSocket, }; #[tokio::test] #[cfg_attr(miri, ignore)] // No Unix domain sockets in miri. async fn datagram_echo_server() -> io::Result<()> { ...
tokio
rust
async_runtime
task_emscripten.rs
#![cfg(all( target_os = "emscripten", not(target_feature = "atomics"), feature = "rt", feature = "macros" ))] /// There is no threadpool on a single-threaded JS worker: the public /// `spawn_blocking` is unsupported on non-pthread emscripten, as on the other /// single-threaded wasm targets. `tokio::fs...
tokio
rust
async_runtime
process_kill_after_wait.rs
#![warn(rust_2018_idioms)] #![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] // Wasi/Miri cannot run system commands use tokio::process::Command; #[tokio::test] async fn kill_after_wait() { let mut cmd; if cfg!(windows) { cmd = Command::new("cmd"); cmd.arg("/c"); } else {...
tokio
rust
async_runtime
fs_link.rs
#![warn(rust_2018_idioms)] #![cfg(all( any( feature = "full", all( target_os = "emscripten", feature = "fs", feature = "macros", feature = "rt", feature = "io-util" ) ), not(target_os = "wasi") ))] // WASI does not support a...
tokio
rust
async_runtime
task_join_set.rs
#![warn(rust_2018_idioms)] #![cfg(any( feature = "full", all( target_os = "emscripten", feature = "rt", feature = "sync", feature = "macros", feature = "time" ) ))] use futures::future::{pending, FutureExt}; use std::panic; use tokio::sync::oneshot; use tokio::task::...
tokio
rust
async_runtime
tcp_socket.rs
#![warn(rust_2018_idioms)] // WASIp1 doesn't support bind #![cfg(all( feature = "net", feature = "macros", feature = "rt", feature = "io-util", not(all(target_os = "wasi", target_env = "p1")), ))] use std::time::Duration; use tokio::net::TcpSocket; use tokio_test::assert_ok; #[tokio::test] async f...
tokio
rust
async_runtime
tracing_sync.rs
#![warn(rust_2018_idioms)] #![cfg(all(tokio_unstable, feature = "tracing", target_has_atomic = "64"))] use std::sync::Mutex; use tokio::sync; use tracing_mock::{expect, subscriber}; // Serialize tests in this file so they cannot race on `tracing-core` callsite // interest registration. static TEST_MUTEX: Mutex<()> = ...
tokio
rust
async_runtime
fs_rename.rs
#![warn(rust_2018_idioms)] #![cfg(all( any( feature = "full", all( target_os = "emscripten", feature = "fs", feature = "macros", feature = "rt", feature = "io-util" ) ), not(target_os = "wasi") ))] // WASI does not support a...
tokio
rust
async_runtime
rt_unstable_eager_driver_handoff.rs
// These tests only work on Unix platforms because they rely on Unix pipes // as a way of generating I/O events from within the same process. // // Also, Miri doesn't like it when you leak a thread, which will happen in // the "deadlock" case below, so we skip these tests on Miri. #![cfg(all(not(miri), unix, feature = ...
tokio
rust
async_runtime
io_emscripten.rs
#![cfg(all( target_os = "emscripten", feature = "io-std", feature = "io-util", feature = "rt", feature = "macros" ))] use tokio::io::{AsyncReadExt, AsyncWriteExt}; #[tokio::test] async fn stdout_write_completes() { let mut out = tokio::io::stdout(); out.write_all(b"hello from stdout\n").aw...
tokio
rust
async_runtime
time_sleep.rs
#![warn(rust_2018_idioms)] #![cfg(any( feature = "full", all( target_os = "emscripten", feature = "rt", feature = "macros", feature = "test-util" ) ))] #![cfg(not(miri))] // Too slow on Miri. use std::future::Future; use std::task::Context; use futures::task::noop_waker_ref...
tokio
rust
async_runtime
io_driver.rs
#![warn(rust_2018_idioms)] // Wasi does not support panic recovery or threading #![cfg(all(feature = "full", not(target_os = "wasi")))] use tokio::net::TcpListener; use tokio::runtime; use tokio_test::{assert_ok, assert_pending}; use futures::task::{waker_ref, ArcWake}; use std::future::Future; use std::net::TcpStrea...
tokio
rust
async_runtime
io_read_buf.rs
#![warn(rust_2018_idioms)] #![cfg(any( feature = "full", all( target_os = "emscripten", feature = "rt", feature = "macros", feature = "io-util" ) ))] use tokio::io::{AsyncRead, AsyncReadExt, ReadBuf}; use tokio_test::assert_ok; use std::io; use std::pin::Pin; use std::task:...
tokio
rust
async_runtime
tracing_time.rs
#![warn(rust_2018_idioms)] #![cfg(all(tokio_unstable, feature = "tracing", target_has_atomic = "64"))] use std::time::Duration; use tokio_test::task; use tracing_mock::{expect, subscriber}; #[tokio::test] async fn test_sleep_creates_span() { let sleep_span_id = expect::id(); let sleep_span = expect::span() ...
tokio
rust
async_runtime
rt_local.rs
#![warn(rust_2018_idioms)] #![cfg(feature = "full")] use std::panic; use tokio::runtime::LocalOptions; use tokio::task::spawn_local; use tokio::task::LocalSet; #[test] fn test_spawn_local_in_runtime() { let rt = rt(); let res = rt.block_on(async move { let (tx, rx) = tokio::sync::oneshot::channel(); ...
tokio
rust
async_runtime
io_read.rs
#![warn(rust_2018_idioms)] #![cfg(any( all(feature = "full", not(target_os = "wasi")), // Wasi does not support panic recovery all( target_os = "emscripten", feature = "rt", feature = "macros", feature = "io-util" ) ))] use tokio::io::{AsyncRead, AsyncReadExt, ReadBuf}; use ...
tokio
rust
async_runtime
process_issue_2174.rs
#![cfg(feature = "process")] #![warn(rust_2018_idioms)] // This test reveals a difference in behavior of kqueue on FreeBSD. When the // reader disconnects, there does not seem to be an `EVFILT_WRITE` filter that // is returned. // // It is expected that `EVFILT_WRITE` would be returned with either the // `EV_EOF` or `E...
tokio
rust
async_runtime
tcp_split.rs
#![warn(rust_2018_idioms)] #![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support peeking use std::io::Result; use std::io::{Read, Write}; use std::{net, thread}; use tokio::io::{AsyncReadExt, AsyncWriteExt}; use tokio::net::TcpStream; #[tokio::test] async fn split() -> Result<()> { cons...
tokio
rust
async_runtime
signal_drop_recv.rs
#![warn(rust_2018_idioms)] #![cfg(feature = "full")] #![cfg(unix)] #![cfg(not(miri))] // No `sigaction` in Miri. mod support { pub mod signal; } use support::signal::send_signal; use tokio::signal::unix::{signal, SignalKind}; #[tokio::test] async fn drop_then_get_a_signal() { let kind = SignalKind::user_defi...
tokio
rust
async_runtime
tcp_accept_ready.rs
#![warn(rust_2018_idioms)] #![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] use futures::FutureExt; use std::future::Future; use std::io::{IoSlice, Write}; use std::pin::pin; use std::task::{Context, Poll}; use tokio::io::{AsyncReadExt, AsyncWriteExt, Interest}; use tokio::net::{TcpListener, TcpStre...
tokio
rust
async_runtime
rt_blocking_thread_exhaust.rs
#![warn(rust_2018_idioms)] #![cfg(all( target_os = "linux", feature = "full", not(miri), not(tokio_no_tuning_tests), panic = "unwind", ))] use std::panic::{self, AssertUnwindSafe}; use std::sync::mpsc; use std::time::Duration; use tokio::runtime::Builder; use tokio::time::timeout; #[test] fn spaw...
tokio
rust
async_runtime
rt_worker_index.rs
#![warn(rust_2018_idioms)] #![cfg(all(feature = "full", not(target_os = "wasi"),))] use std::sync::Arc; use std::thread; use tokio::runtime::{self, Runtime}; #[test] fn worker_index_current_thread() { let rt = runtime::Builder::new_current_thread() .enable_all() .build() .unwrap(); rt...