Something went wrong. Try again.
And Iroh inspired WebRTC experiment
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051use bytes::Bytes;use std::{fmt, sync::Arc};
/// Application-provided connection close information, preserved across either transport.#[derive(Debug, Clone, PartialEq, Eq)]pub struct ApplicationClose { pub error_code: u32, pub reason: Bytes,}/// Terminal connection state. The first close wins.#[derive(Debug, Clone, PartialEq, Eq)]pub enum ConnectionError { LocallyClosed, ApplicationClosed(ApplicationClose), TransportClosed(Arc<str>),}impl fmt::Display for ConnectionError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { Self::LocallyClosed => f.write_str("connection locally closed"), Self::ApplicationClosed(c) => write!( f, "application closed connection ({}): {}", c.error_code, String::from_utf8_lossy(&c.reason) ), Self::TransportClosed(reason) => write!(f, "connection lost: {reason}"), } }}impl std::error::Error for ConnectionError {}/// Directional stream errors. Reset/stop affect one direction, not the entire connection.#[derive(Debug, Clone, PartialEq, Eq)]pub enum StreamError { ClosedStream, Reset(u32), Stopped(u32), ConnectionLost(ConnectionError),}impl fmt::Display for StreamError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { Self::ClosedStream => f.write_str("stream closed"), Self::Reset(code) => write!(f, "stream reset ({code})"), Self::Stopped(code) => write!(f, "stream stopped ({code})"), Self::ConnectionLost(reason) => reason.fmt(f), } }}impl std::error::Error for StreamError {}