bsoneach v0.3.2 BSONEach
This module allows to apply callback
function to each document in a BSON file.
Source file should be opened in :binary mode.
Examples
"sample.bson"
|> BSONEach.File.open
|> BSONEach.each(&IO.inspect/1)
|> File.close
Callback function can return :stop
atom to tell BSONEach to stop reading file and exit with error.
Any other result will be counted as :ok.
Examples
def callback do
:stop # Tell BSONEach to stop parsing file
end
Summary
Functions
This method allows to apply callback
function to each document in a BSON file
Functions
Specs
each(IO.device | File.Stream.t, Func) ::
IO.iodata |
IO.nodata
This method allows to apply callback
function to each document in a BSON file.
Source file should be opened in :binary
, :raw
modes. BSONEach can accept file streams.
It returns:
io_device
- when file is parsed successfully.{:parse_error, reason}
- in case there was an error while parsing BSON document. Possible reasons::corrupted_document
.{:io_error, reason}
- in case IO.binstream returned an error.{:error, :callback_canceled}
- in cases when callback function returned:stop
atom to canceled file processing.
Examples
"sample.bson"
|> File.open!([:read, :binary, :raw])
|> BSONEach.each(&IO.inspect/1)
|> File.close