Skip to main content

Crate vibeio_hyper

Crate vibeio_hyper 

Source
Expand description

A compatibility layer for using hyper with the vibeio async runtime.

This crate provides the necessary adapters to run hyper-based HTTP servers and clients on top of vibeio instead of tokio. It implements the traits required by hyper’s runtime abstraction:

  • VibeioExecutor: An executor that spawns tasks on the vibeio runtime using vibeio::spawn.
  • VibeioTimer: A timer that uses vibeio::time::sleep for delay operations.
  • VibeioIo: A wrapper type that adapts vibeio’s I/O types to implement hyper’s Read and Write traits, and also implements tokio’s AsyncRead and AsyncWrite traits for compatibility.

§Overview

This crate enables hyper to work with vibeio by implementing hyper’s runtime traits (Executor, Timer, Read, Write, Sleep) in terms of vibeio primitives.

§Executor

The VibeioExecutor type implements hyper::rt::Executor by spawning futures onto the vibeio runtime via vibeio::spawn.

§Timer

The VibeioTimer type implements hyper::rt::Timer by converting sleep requests into vibeio::time::sleep futures wrapped in a compatible type.

§I/O Adapters

The VibeioIo<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 VibeioIo wrapper uses Pin<Box<T>> internally to support the trait implementations required by hyper and tokio.
  • The VibeioSleep type (internal) implements both hyper::rt::Sleep and std::future::Future to bridge the two runtimes’ sleep abstractions.
  • Timer handles are properly cancelled when VibeioSleep is dropped to avoid resource leaks.

Structs§

VibeioExecutor
An executor that spawns tasks onto the vibeio runtime.
VibeioIo
A wrapper type that adapts I/O types for use with hyper and tokio.
VibeioTimer
A timer that uses vibeio’s time utilities for sleep operations.