pub struct Schema { /* private fields */ }Expand description
Represents the avro schema used to write encoded avro data.
Implementations§
Source§impl Schema
impl Schema
Sourcepub fn from_path<P: AsRef<Path> + Debug>(path: P) -> Result<Self, AvrowErr>
pub fn from_path<P: AsRef<Path> + Debug>(path: P) -> Result<Self, AvrowErr>
Parses an avro schema from a JSON schema in a file.
Alternatively, one can use the FromStr
impl to create the Schema from a JSON string:
use std::str::FromStr;
use avrow::Schema;
let schema = Schema::from_str(r##""null""##).unwrap();Sourcepub fn canonical_form(&self) -> &CanonicalSchema
pub fn canonical_form(&self) -> &CanonicalSchema
Returns the canonical form of an Avro schema. Example:
use avrow::Schema;
use std::str::FromStr;
let schema = Schema::from_str(r##"
{
"type": "record",
"name": "LongList",
"aliases": ["LinkedLongs"],
"fields" : [
{"name": "value", "type": "long"},
{"name": "next", "type": ["null", "LongList"]
}]
}
"##).unwrap();
let canonical = schema.canonical_form();Trait Implementations§
Auto Trait Implementations§
impl Freeze for Schema
impl RefUnwindSafe for Schema
impl Send for Schema
impl Sync for Schema
impl Unpin for Schema
impl UnwindSafe for Schema
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more