Enum apache_avro::schema::Schema
source · pub enum Schema {
Show 25 variants
Null,
Boolean,
Int,
Long,
Float,
Double,
Bytes,
String,
Array(Box<Schema>),
Map(Box<Schema>),
Union(UnionSchema),
Record(RecordSchema),
Enum(EnumSchema),
Fixed(FixedSchema),
Decimal(DecimalSchema),
Uuid,
Date,
TimeMillis,
TimeMicros,
TimestampMillis,
TimestampMicros,
LocalTimestampMillis,
LocalTimestampMicros,
Duration,
Ref {
name: Name,
},
}
Expand description
Represents any valid Avro schema More information about Avro schemas can be found in the Avro Specification
Variants§
Null
A null
Avro schema.
Boolean
A boolean
Avro schema.
Int
An int
Avro schema.
Long
A long
Avro schema.
Float
A float
Avro schema.
Double
A double
Avro schema.
Bytes
A bytes
Avro schema.
Bytes
represents a sequence of 8-bit unsigned bytes.
String
A string
Avro schema.
String
represents a unicode character sequence.
Array(Box<Schema>)
A array
Avro schema. Avro arrays are required to have the same type for each element.
This variant holds the Schema
for the array element type.
Map(Box<Schema>)
A map
Avro schema.
Map
holds a pointer to the Schema
of its values, which must all be the same schema.
Map
keys are assumed to be string
.
Union(UnionSchema)
A union
Avro schema.
Record(RecordSchema)
A record
Avro schema.
Enum(EnumSchema)
An enum
Avro schema.
Fixed(FixedSchema)
A fixed
Avro schema.
Decimal(DecimalSchema)
Logical type which represents Decimal
values. The underlying type is serialized and
deserialized as Schema::Bytes
or Schema::Fixed
.
Uuid
A universally unique identifier, annotating a string.
Date
Logical type which represents the number of days since the unix epoch.
Serialization format is Schema::Int
.
TimeMillis
The time of day in number of milliseconds after midnight with no reference any calendar, time zone or date in particular.
TimeMicros
The time of day in number of microseconds after midnight with no reference any calendar, time zone or date in particular.
TimestampMillis
An instant in time represented as the number of milliseconds after the UNIX epoch.
TimestampMicros
An instant in time represented as the number of microseconds after the UNIX epoch.
LocalTimestampMillis
An instant in localtime represented as the number of milliseconds after the UNIX epoch.
LocalTimestampMicros
An instant in local time represented as the number of microseconds after the UNIX epoch.
Duration
An amount of time defined by a number of months, days and milliseconds.
Ref
A reference to another schema.
Implementations§
source§impl Schema
impl Schema
sourcepub fn canonical_form(&self) -> String
pub fn canonical_form(&self) -> String
Converts self
into its Parsing Canonical Form.
sourcepub fn fingerprint<D: Digest>(&self) -> SchemaFingerprint
pub fn fingerprint<D: Digest>(&self) -> SchemaFingerprint
Generate fingerprint of Schema’s Parsing Canonical Form.
sourcepub fn parse_str(input: &str) -> Result<Schema, Error>
pub fn parse_str(input: &str) -> Result<Schema, Error>
Create a Schema
from a string representing a JSON Avro schema.
sourcepub fn parse_list(input: &[&str]) -> AvroResult<Vec<Schema>>
pub fn parse_list(input: &[&str]) -> AvroResult<Vec<Schema>>
Create a array of Schema
’s from a list of named JSON Avro schemas (Record, Enum, and
Fixed).
It is allowed that the schemas have cross-dependencies; these will be resolved during parsing.
If two of the input schemas have the same fullname, an Error will be returned.
sourcepub fn parse_reader(reader: &mut (impl Read + ?Sized)) -> AvroResult<Schema>
pub fn parse_reader(reader: &mut (impl Read + ?Sized)) -> AvroResult<Schema>
Create a Schema
from a reader which implements Read
.
sourcepub fn parse(value: &Value) -> AvroResult<Schema>
pub fn parse(value: &Value) -> AvroResult<Schema>
Parses an Avro schema from JSON.