[−][src]Crate avrow
Avrow is a pure Rust implementation of the Apache Avro specification.
Pleaes refer to the README for an overview. For more details on the spec, head over to the FAQ.
Using the library
Add to your Cargo.toml
:
[dependencies]
avrow = "0.2.0"
A hello world example of reading and writing avro data files
use avrow::{Reader, Schema, Writer, from_value}; use std::str::FromStr; use anyhow::Error; fn main() -> Result<(), Error> { // Writing data // Create a schema let schema = Schema::from_str(r##""null""##)?; // Create writer using schema and provide a buffer to write to let mut writer = Writer::new(&schema, vec![])?; // Write data using write writer.write(())?; // or serialize writer.serialize(())?; // retrieve the underlying buffer using the into_inner method. let buf = writer.into_inner()?; // Reading data // Create Reader by providing a Read wrapped version of `buf` let reader = Reader::new(buf.as_slice())?; // Use iterator for reading data in an idiomatic manner. for i in reader { // reading values can fail due to decoding errors, so the return value of iterator is a Option<Result<Value>> // it allows one to examine the failure reason on the underlying avro reader. dbg!(&i); // This value can be converted to a native Rust type using from_value method from the serde impl. let _: () = from_value(&i)?; } Ok(()) }
Modules
config | This module contains constants and configuration parameters for configuring avro writers and readers. |
Macros
fixed | Convenient macro to create a avro fixed value |
Structs
Header | Header represents the avro datafile header. |
Reader | Reader is the primary interface for reading data from an avro datafile. |
Record | The record avro type |
Schema | Represents the avro schema used to write encoded avro data |
Writer | The Writer is the primary interface for writing values to an avro datafile or a byte container (say a |
WriterBuilder | Convenient builder struct for configuring and instantiating a Writer. |
Enums
AvrowErr | Errors returned from avrow |
Codec | Defines codecs one can use when writing avro data. |
Value | Represents an Avro value |
Functions
from_value |
|
to_value |
|