Skip to main content

Crate zerodds_http2

Crate zerodds_http2 

Source
Expand description

Crate zerodds-http2. Safety classification: STANDARD.

HTTP/2 (RFC 9113) Wire-Codec — no_std Framing + Stream-State- Machine + Flow-Control + Connection-Preface + Settings. forbid(unsafe_code). Implementiert die Wire-Schicht von HTTP/2 ohne Heap-Buffering oder Async-Runtime: Frames werden in/aus byte-Slices kodiert/dekodiert, die State-Machine ist callback- basiert.

Hinweis: RFC 9113 (HTTP/2) hat RFC 7540 abgeloest, behaelt das Wire-Format und die meisten §-Nummern bei und entfernt einige ungenutzte Features (Priority, Hint-Direktiven). Diese Crate folgt RFC 9113.

Spec: RFC 9113 §3 (Connection-Preface) + §4 (Frame-Layer) + §5 (Streams + Multiplexing) + §6 (Frame-Definitions) + §7 (Error- Codes).

§Schichten-Position

Layer 5 — Bridges. Substrat fuer:

§Public API (Stand 1.0.0-rc.1)

§Beispiel

use zerodds_http2::{FrameHeader, FrameType, Flags, encode_frame, decode_frame};
use zerodds_http2::frame::DEFAULT_MAX_FRAME_SIZE;

// PING-Frame (8-Byte-Opaque-Payload, Stream-ID 0).
let payload = [0u8; 8];
let header = FrameHeader {
    length: 8,
    frame_type: FrameType::Ping,
    flags: Flags(0),
    stream_id: 0,
};

let mut buf = [0u8; 17]; // 9-Byte-Header + 8-Byte-Payload
let written = encode_frame(&header, &payload, &mut buf, DEFAULT_MAX_FRAME_SIZE)
    .expect("encode");
assert_eq!(written, 17);

let (decoded, consumed) = decode_frame(&buf, DEFAULT_MAX_FRAME_SIZE).expect("decode");
assert_eq!(consumed, 17);
assert_eq!(decoded.header.frame_type, FrameType::Ping);

Re-exports§

pub use error::ErrorCode;
pub use error::Http2Error;
pub use flow::FlowControl;
pub use frame::Flags;
pub use frame::Frame;
pub use frame::FrameHeader;
pub use frame::FrameType;
pub use frame::decode_frame;
pub use frame::encode_frame;
pub use preface::CLIENT_PREFACE;
pub use preface::check_preface;
pub use settings::Setting;
pub use settings::SettingId;
pub use settings::Settings;
pub use stream::StreamId;
pub use stream::StreamState;

Modules§

error
HTTP/2 Error-Codes — RFC 9113 §7.
flow
Flow-Control — RFC 9113 §5.2 + §6.9.
frame
Frame-Layer — RFC 9113 §4 + §6.
preface
Connection-Preface — RFC 9113 §3.4.
settings
SETTINGS Frame — RFC 9113 §6.5.
stream
Stream-State-Machine — RFC 9113 §5.1.