Ankh.HTTP2.Frame (ankh v0.14.4)

HTTP/2 frame struct

The using macro injects the frame struct needed by Ankh.HTTP2.Frame.

Link to this section Summary

Types

Frame data

Frame length

Encode/Decode options

t()

Struct injected by the Ankh.HTTP2.Frame using macro.

Frame type code

Functions

Injects the frame struct in a module.

Decodes a binary into a frame struct

Encodes a frame struct into binary

Returns s tream of frames from a buffer, returning the leftover buffer data and the frame header information and data (without decoding it) in a tuple

Link to this section Types

Specs

data() :: iodata()

Frame data

Specs

length() :: non_neg_integer()

Frame length

Specs

options() :: keyword()

Encode/Decode options

Specs

t() :: struct()

Struct injected by the Ankh.HTTP2.Frame using macro.

Specs

type() :: non_neg_integer()

Frame type code

Link to this section Functions

Link to this macro

__using__(args)

(macro)

Specs

__using__(type: type(), flags: atom() | nil, payload: atom() | nil) :: Macro.t()

Injects the frame struct in a module.

Link to this function

decode(frame, data, options \\ [])

Specs

decode(t(), binary(), options()) :: {:ok, t()} | {:error, any()}

Decodes a binary into a frame struct

Parameters:

  • struct: struct using Ankh.HTTP2.Frame
  • binary: data to decode into the struct
  • options: options to pass as context to the decoding function
Link to this function

encode(frame, options \\ [])

Specs

encode(t(), options()) :: {:ok, t(), data()} | {:error, any()}

Encodes a frame struct into binary

Parameters:

  • struct: struct using Ankh.HTTP2.Frame
  • options: options to pass as context to the encoding function

Specs

stream(iodata()) :: Enumerable.t()

Returns s tream of frames from a buffer, returning the leftover buffer data and the frame header information and data (without decoding it) in a tuple:

{remaining_buffer, {length, type, id, frame_data}}

or nil to signal partial leftover data:

{remaining_buffer, nil}