Expand description
A compatibility layer for using hyper with the zincio async runtime.
This crate provides the necessary adapters to run hyper-based HTTP servers
and clients on top of zincio instead of tokio. It implements the traits
required by hyper’s runtime abstraction:
ZincioExecutor: An executor that spawns tasks on thezincioruntime usingzincio::spawn.ZincioTimer: A timer that useszincio::time::sleepfor delay operations.ZincioIo: A wrapper type that adaptszincio’s I/O types to implementhyper’sReadandWritetraits, and also implementstokio’sAsyncReadandAsyncWritetraits for compatibility.
§Overview
This crate enables hyper to work with zincio by implementing hyper’s
runtime traits (Executor, Timer, Read, Write, Sleep) in terms of
zincio primitives.
§Executor
The ZincioExecutor type implements hyper::rt::Executor by spawning
futures onto the zincio runtime via zincio::spawn.
§Timer
The ZincioTimer type implements hyper::rt::Timer by converting sleep
requests into zincio::time::sleep futures wrapped in a compatible type.
§I/O Adapters
The ZincioIo<T> wrapper adapts any type that implements tokio::io::AsyncRead
and tokio::io::AsyncWrite to work with hyper’s I/O traits. It also
implements the reverse conversion, allowing hyper’s I/O types to be used
with tokio-style async functions.
§Implementation notes
- The
ZincioIowrapper usesPin<Box<T>>internally to support the trait implementations required byhyperandtokio. - The
ZincioSleeptype (internal) implements bothhyper::rt::Sleepandstd::future::Futureto bridge the two runtimes’ sleep abstractions. - Timer handles are properly cancelled when
ZincioSleepis dropped to avoid resource leaks.
Structs§
- Zincio
Executor - An executor that spawns tasks onto the
zincioruntime. - Zincio
Io - A wrapper type that adapts I/O types for use with
hyperandtokio. - Zincio
Timer - A timer that uses
zincio’s time utilities for sleep operations.