Skip to main content
pub struct AvroSchemaBuilder  /* private fields */ 

Builder for constructing Avro record schemas programmatically

Example

Implementations

Source

pub fn new(name: impl Into<String>) -> Self

Creates a new schema builder with the given record name

Source

pub fn namespace(self, namespace: impl Into<String>) -> Self

Sets the namespace for the record

Source

pub fn doc(self, doc: impl Into<String>) -> Self

Sets the documentation for the record

Source

pub fn field(self, name: impl Into<String>, avro_type: AvroType) -> Self

Adds a field with the given name and type

Source

pub fn field_with_doc( self, name: impl Into<String>, avro_type: AvroType, doc: impl Into<String>, ) -> Self

Adds a field with documentation

Source

pub fn nullable_field( self, name: impl Into<String>, avro_type: AvroType, ) -> Self

Adds a nullable field (shorthand for field(name, AvroType::Nullable(…)))

Source

pub fn int_field(self, name: impl Into<String>) -> Self

Adds an integer field

Source

pub fn long_field(self, name: impl Into<String>) -> Self

Adds a long (i64) field

Source

pub fn float_field(self, name: impl Into<String>) -> Self

Adds a float field

Source

pub fn double_field(self, name: impl Into<String>) -> Self

Adds a double field

Source

pub fn string_field(self, name: impl Into<String>) -> Self

Adds a string field

Source

pub fn bool_field(self, name: impl Into<String>) -> Self

Adds a boolean field: an Avro int, as Kinetica stores a boolean (give the column the boolean property). The struct’s bool field must be written as an int, with #[serde(with = “gpudb_api::avro_schema_builder::bool_as_int”)] (see bool_as_int); unannotated, it fails to encode.

Source

pub fn bytes_field(self, name: impl Into<String>) -> Self

Adds a bytes field

Source

pub fn timestamp_field(self, name: impl Into<String>) -> Self

Adds a timestamp field (long type, typically milliseconds since epoch)

Source

pub fn nullable_string_field(self, name: impl Into<String>) -> Self

Adds a nullable string field

Source

pub fn nullable_int_field(self, name: impl Into<String>) -> Self

Adds a nullable int field

Source

pub fn nullable_long_field(self, name: impl Into<String>) -> Self

Adds a nullable long field

Source

pub fn nullable_double_field(self, name: impl Into<String>) -> Self

Adds a nullable double field

Source

pub fn nullable_bytes_field(self, name: impl Into<String>) -> Self

Adds a nullable bytes field

Source

pub fn build(&self) -> String

Builds the Avro schema JSON string

Source

pub fn build_static(&self) -> &‘static str

Builds the schema and leaks it to get a &‘static str

This is useful for implementing KineticaRecord::avro_schema() which requires returning &‘static str. The memory is intentionally leaked since schemas are typically created once and live for the program’s lifetime.

Trait Implementations

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source

fn fmt(&self, f: &mut Formatter<’_>) -> Result

Formats the value using the given formatter. Read more