|
12 | 12 | //! ### A hello world example of reading and writing avro data files
|
13 | 13 |
|
14 | 14 | //!```rust
|
15 |
| -//!use avrow::{Reader, Schema, Writer, from_value}; |
16 |
| -//!use std::str::FromStr; |
17 |
| -//!use std::error::Error; |
| 15 | +//! use avrow::{Reader, Schema, Writer, from_value}; |
| 16 | +//! use std::str::FromStr; |
| 17 | +//! use anyhow::Error; |
18 | 18 | //!
|
19 |
| -//!use std::io::Cursor; |
| 19 | +//! fn main() -> Result<(), Error> { |
| 20 | +//! // Writing data |
20 | 21 | //!
|
21 |
| -//!fn main() -> Result<(), Box<dyn Error>> { |
22 |
| -//! // Writing data |
| 22 | +//! // Create a schema |
| 23 | +//! let schema = Schema::from_str(r##""null""##)?; |
| 24 | +//! // Create writer using schema and provide a buffer to write to |
| 25 | +//! let mut writer = Writer::new(&schema, vec![])?; |
| 26 | +//! // Write data using write |
| 27 | +//! writer.write(())?; |
| 28 | +//! // or serialize |
| 29 | +//! writer.serialize(())?; |
| 30 | +//! // retrieve the underlying buffer using the into_inner method. |
| 31 | +//! let buf = writer.into_inner()?; |
23 | 32 | //!
|
24 |
| -//! // Create a schema |
25 |
| -//! let schema = Schema::from_str(r##""null""##)?; |
26 |
| -//! // Create writer using schema and provide a buffer to write to |
27 |
| -//! let mut writer = Writer::new(&schema, vec![])?; |
28 |
| -//! // Write the data using append |
29 |
| -//! writer.serialize(())?; |
30 |
| -//! // or serialize |
31 |
| -//! writer.serialize(())?; |
32 |
| -//! // retrieve the underlying buffer using the into_inner method. |
33 |
| -//! let buf = writer.into_inner()?; |
| 33 | +//! // Reading data |
34 | 34 | //!
|
35 |
| -//! // Reading data |
36 |
| -//! |
37 |
| -//! // Create Reader by providing a Read wrapped version of `buf` |
38 |
| -//! let reader = Reader::new(buf.as_slice())?; |
39 |
| -//! // Use iterator for reading data in an idiomatic manner. |
40 |
| -//! for i in reader { |
41 |
| -//! // reading values can fail due to decoding errors, so the return value of iterator is a Option<Result<Value>> |
42 |
| -//! // it allows one to examine the failure reason on the underlying avro reader. |
43 |
| -//! dbg!(&i); |
44 |
| -//! // This value can be converted to a native Rust type using from_value method from the serde impl. |
45 |
| -//! let _: () = from_value(&i)?; |
46 |
| -//! } |
47 |
| -//! |
48 |
| -//! Ok(()) |
49 |
| -//!} |
| 35 | +//! // Create Reader by providing a Read wrapped version of `buf` |
| 36 | +//! let reader = Reader::new(buf.as_slice())?; |
| 37 | +//! // Use iterator for reading data in an idiomatic manner. |
| 38 | +//! for i in reader { |
| 39 | +//! // reading values can fail due to decoding errors, so the return value of iterator is a Option<Result<Value>> |
| 40 | +//! // it allows one to examine the failure reason on the underlying avro reader. |
| 41 | +//! dbg!(&i); |
| 42 | +//! // This value can be converted to a native Rust type using from_value method from the serde impl. |
| 43 | +//! let _: () = from_value(&i)?; |
| 44 | +//! } |
50 | 45 | //!
|
| 46 | +//! Ok(()) |
| 47 | +//! } |
| 48 | +
|
51 | 49 | //!```
|
52 | 50 |
|
53 | 51 | // TODO update logo
|
54 |
| -#![doc(html_favicon_url = "")] |
55 |
| -#![doc(html_logo_url = "assets/avrow_logo.png")] |
| 52 | +#![doc( |
| 53 | + html_favicon_url = "https://raw.githubusercontent.com/creativcoder/avrow/main/assets/avrow_logo.png" |
| 54 | +)] |
| 55 | +#![doc( |
| 56 | + html_logo_url = "https://raw.githubusercontent.com/creativcoder/avrow/main/assets/avrow_logo.png" |
| 57 | +)] |
56 | 58 | #![deny(missing_docs)]
|
57 | 59 | #![recursion_limit = "1024"]
|
58 | 60 | #![deny(unused_must_use)]
|
59 |
| -// #![deny(warnings)] |
| 61 | +#![deny(rust_2018_idioms)] |
| 62 | +#![deny(warnings)] |
60 | 63 |
|
61 | 64 | mod codec;
|
62 | 65 | pub mod config;
|
|
0 commit comments