Packages
ankh
0.8.7
0.17.0
0.16.0
0.15.0
0.14.5
0.14.4
0.14.3
0.14.2
0.14.1
0.14.0
0.13.0
0.12.1
0.12.0
0.11.0
0.10.0
0.9.0
0.8.11
0.8.10
0.8.9
0.8.8
0.8.7
0.8.6
0.8.5
0.8.4
0.8.3
0.8.2
0.8.1
0.8.0
0.7.2
0.7.1
0.7.0
0.6.0
0.5.3
0.5.2
0.5.1
0.5.0
0.4.6
0.4.5
0.4.4
0.4.3
0.4.2
0.4.1
0.4.0
0.3.1
0.3.0
0.1.1
0.1.0
0.0.5
0.0.4
0.0.3
0.0.2
0.0.1
Pure Elixir HTTP/2 implementation
Current section
Files
Jump to
Current section
Files
lib/ankh/http2/frame/priority.ex
defmodule Ankh.HTTP2.Frame.Priority do
@moduledoc false
defmodule Payload do
@moduledoc false
@type t :: %__MODULE__{exclusive: boolean, stream_dependency: integer, weight: integer}
defstruct exclusive: false, stream_dependency: 0, weight: 0
end
alias __MODULE__.Payload
use Ankh.HTTP2.Frame, type: 0x2, payload: Payload
end
defimpl Ankh.HTTP2.Frame.Encodable, for: Ankh.HTTP2.Frame.Priority.Payload do
def decode(payload, <<1::1, sd::31, wh::8>>, _) do
{:ok, %{payload | exclusive: true, stream_dependency: sd, weight: wh}}
end
def decode(payload, <<0::1, sd::31, wh::8>>, _) do
{:ok, %{payload | exclusive: false, stream_dependency: sd, weight: wh}}
end
def decode(_payload, _data, _options), do: {:error, :decode_error}
def encode(%{exclusive: true, stream_dependency: sd, weight: wh}, _) do
{:ok, [<<1::1, sd::31, wh::8>>]}
end
def encode(%{exclusive: false, stream_dependency: sd, weight: wh}, _) do
{:ok, [<<0::1, sd::31, wh::8>>]}
end
def encode(_payload, _options), do: {:error, :encode_error}
end