Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

lok0613/elixir-binary-reader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

2 Commits

Repository 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)

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

AltStyle によって変換されたページ (->オリジナル) /