DefaultProvider

Trait DefaultProvider 

Source
pub trait DefaultProvider: Send + Sync {
    // Required methods
    fn default_bytes(&self, field: &str, type_name: &str) -> Option<Vec<u8>>;
    fn default_string(&self, field: &str, type_name: &str) -> Option<String>;
    fn has_default(&self, field: &str) -> bool;
    fn fields_with_defaults(&self) -> Vec<String>;
}
Expand description

Default value provider for schema fields.

Implementations provide default values for fields in a schema, which are used when migrating data from older versions that lack certain fields.

Required Methods§

Source

fn default_bytes(&self, field: &str, type_name: &str) -> Option<Vec<u8>>

Get the default value for a field as bytes.

§Arguments
  • field - The field name
  • type_name - The field’s type name
§Returns

The default value as bytes (for arena storage), or None if no default.

Source

fn default_string(&self, field: &str, type_name: &str) -> Option<String>

Get the default value for a field as a string representation.

This is useful for debugging and display purposes.

Source

fn has_default(&self, field: &str) -> bool

Check if a field has a default value.

Source

fn fields_with_defaults(&self) -> Vec<String>

Get all fields that have defaults.

Implementors§