Skip to content

Latest commit

 

History

2 提交

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

仓库 files navigation

BinaryReader

A Elixir Binary Reader that running WITH side effects.

Installation

def deps do
  [
    {:binary_reader, "~> 0.1.0"}
  ]
end

Usage

Normal Usage

iex> {:ok, pid} = BinaryReader.start_link(<<65, 66, 67, 68, 2, 0, 0, 0>>)
{:ok, #PID<0.0.0>}
iex> BinaryReader.read_string(pid)
"ABCD"
iex> BinaryReader.remains_byte_size(pid)
4
iex> BinaryReader.read_int32(pid)
2
iex> BinaryReader.stop(pid)
:ok

Extend BinaryReader

defmodule SpecialBinaryReader do
  use BinaryReader

  def special_read(pid) do
    length = read_int32(pid)
    read_bytes(pid, length)
  end
end

iex> {:ok, pid} = SpecialBinaryReader.start_link(<<.....>>)
iex> SpecialBinaryReader.special_read(pid)

关于

No description or website provided.

Topics

Resources

Stars

1 star

关注者

1 watching

复刻s

发布

贡献者

Languages