h2_frame

Types

pub type FrameError {
  HeaderError(header.HeaderError)
  ConnectionError(error.ErrorCode)
  IncompletePayload
  InvalidPadding
}

Constructors

pub type Payload {
  Data(end_stream: Bool, data: BitArray)
  Headers(
    end_stream: Bool,
    end_headers: Bool,
    priority: option.Option(StreamPriority),
    data: BitArray,
  )
  Priority(exclusive: Bool, stream_dependency: Int, weight: Int)
  RstStream(error_code: error.ErrorCode)
  Settings(ack: Bool, settings: List(Setting))
  PushPromise(
    end_headers: Bool,
    promised_stream_id: Int,
    data: BitArray,
  )
  Ping(ack: Bool, data: BitArray)
  GoAway(
    last_stream_id: Int,
    error_code: error.ErrorCode,
    debug_data: BitArray,
  )
  WindowUpdate(window_size_increment: Int)
  Continuation(end_headers: Bool, data: BitArray)
  Unknown(data: BitArray)
}

Constructors

  • Data(end_stream: Bool, data: BitArray)
  • Headers(
      end_stream: Bool,
      end_headers: Bool,
      priority: option.Option(StreamPriority),
      data: BitArray,
    )
  • Priority(exclusive: Bool, stream_dependency: Int, weight: Int)
  • RstStream(error_code: error.ErrorCode)
  • Settings(ack: Bool, settings: List(Setting))
  • PushPromise(
      end_headers: Bool,
      promised_stream_id: Int,
      data: BitArray,
    )
  • Ping(ack: Bool, data: BitArray)
  • GoAway(
      last_stream_id: Int,
      error_code: error.ErrorCode,
      debug_data: BitArray,
    )
  • WindowUpdate(window_size_increment: Int)
  • Continuation(end_headers: Bool, data: BitArray)
  • Unknown(data: BitArray)
pub type Setting {
  HeaderTableSize(Int)
  EnablePush(Int)
  MaxConcurrentStreams(Int)
  InitialWindowSize(Int)
  MaxFrameSize(Int)
  MaxHeaderListSize(Int)
  UnknownSetting(id: Int, value: Int)
}

Constructors

  • HeaderTableSize(Int)
  • EnablePush(Int)
  • MaxConcurrentStreams(Int)
  • InitialWindowSize(Int)
  • MaxFrameSize(Int)
  • MaxHeaderListSize(Int)
  • UnknownSetting(id: Int, value: Int)
pub type StreamPriority {
  StreamPriority(
    exclusive: Bool,
    stream_dependency: Int,
    weight: Int,
  )
}

Constructors

  • StreamPriority(
      exclusive: Bool,
      stream_dependency: Int,
      weight: Int,
    )

Values

pub fn encode_continuation(
  stream_id stream_id: Int,
  end_headers end_headers: Bool,
  data data: BitArray,
) -> Result(BitArray, FrameError)
pub fn encode_data(
  stream_id stream_id: Int,
  end_stream end_stream: Bool,
  data data: BitArray,
  padding padding: option.Option(Int),
) -> Result(BitArray, FrameError)
pub fn encode_goaway(
  last_stream_id last_stream_id: Int,
  error_code error_code: error.ErrorCode,
  debug_data debug_data: BitArray,
) -> BitArray
pub fn encode_headers(
  stream_id stream_id: Int,
  end_stream end_stream: Bool,
  end_headers end_headers: Bool,
  priority priority: option.Option(StreamPriority),
  data data: BitArray,
  padding padding: option.Option(Int),
) -> Result(BitArray, FrameError)
pub fn encode_ping(
  ack ack: Bool,
  data data: BitArray,
) -> Result(BitArray, FrameError)
pub fn encode_priority(
  stream_id stream_id: Int,
  exclusive exclusive: Bool,
  stream_dependency stream_dependency: Int,
  weight weight: Int,
) -> Result(BitArray, FrameError)
pub fn encode_push_promise(
  stream_id stream_id: Int,
  end_headers end_headers: Bool,
  promised_stream_id promised_stream_id: Int,
  data data: BitArray,
  padding padding: option.Option(Int),
) -> Result(BitArray, FrameError)
pub fn encode_rst_stream(
  stream_id stream_id: Int,
  error_code error_code: error.ErrorCode,
) -> Result(BitArray, FrameError)
pub fn encode_settings(
  ack ack: Bool,
  settings settings: List(Setting),
) -> Result(BitArray, FrameError)
pub fn encode_unknown(
  frame_type_code frame_type_code: Int,
  stream_id stream_id: Int,
  flags flags: Int,
  data data: BitArray,
) -> BitArray
pub fn encode_window_update(
  stream_id stream_id: Int,
  window_size_increment window_size_increment: Int,
) -> Result(BitArray, FrameError)
pub fn parse(
  data: BitArray,
) -> Result(#(header.FrameHeader, Payload, BitArray), FrameError)

Parses a complete HTTP/2 frame from binary data. Returns the frame header, payload, and any remaining bytes that follow the frame.

pub fn parse_payload(
  frame_header: header.FrameHeader,
  data: BitArray,
) -> Result(#(Payload, BitArray), FrameError)

Parses a frame payload given an already-parsed frame header. Returns the decoded payload and any remaining bytes after the frame.

Search Document