Packages
term_stream
0.1.0
A library for serializing and unserializing Erlang terms to and from a binary stream.
Current section
Files
Jump to
Current section
Files
term_stream
README.md
README.md
# Erlang Term Streaming

[](https://hex.pm/packages/term_stream)
A Library for streaming Erlang terms into and out of binary streams. This is especially useful when storing large numbers of Erlang terms to file for later retrieval. When dealing with large files containing lots of Erlang terms, having to load the entire list into memory can be problematice. Using `TermStream` allows you to stream the terms one at a time out of the file.
## Example
```elixir
# To write a stream of terms to a file:
file = File.stream!("my_file", [:write, :binary])
other_stream
|> TermStream.serialize()
|> Stream.into(file)
|> Stream.run()
File.close(file)
# The get a stream out of the same file later:
File.stream!("my_file", 1024, [:read, :binary])
|> TermStream.deserialize()
|> Stream.run()
```
## Installation
```elixir
defp deps do
[{:term_stream, "~> 0.1.0"}]
end
```