Skip to content

bsm/pbio

Repository files navigation

PB IO

Test License

Protobuf IO is a Ruby equivalent of https://godoc.org/github.com/gogo/protobuf/io.

Installation

Add gem 'pbio' to your Gemfile.

Usage

File.open("file.txt", "w") do |f|
  pbio = PBIO::Delimited.new(f)
  pbio.write MyProtoMsg.new(title: "Foo")
  pbio.write MyProtoMsg.new(title: "Bar")
end

File.open("file.txt", "r") do |f|
  pbio = PBIO::Delimited.new(f)
  pbio.read MyProtoMsg # => #<MyProtoMsg: title: "Foo">
  pbio.read MyProtoMsg # => #<MyProtoMsg: title: "Bar">
  pbio.read MyProtoMsg # => nil
  f.eof?               # => true
end

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published