Skip to main content

KoreSchema

Struct KoreSchema 

Source
pub struct KoreSchema {
    pub current_version: SchemaVersion,
    pub columns: Vec<SchemaField>,
    pub column_index: HashMap<String, usize>,
    pub aliases: HashMap<String, String>,
    pub history: Vec<SchemaHistoryEntry>,
    pub deleted_columns: BTreeMap<String, SchemaField>,
    pub type_conversions: HashMap<String, TypeConversionRule>,
}
Expand description

Complete schema at a specific version

Fields§

§current_version: SchemaVersion

Current version number

§columns: Vec<SchemaField>

Active (non-deleted) columns

§column_index: HashMap<String, usize>

Map from column name to column index

§aliases: HashMap<String, String>

Column name aliases (old_name → new_name)

§history: Vec<SchemaHistoryEntry>

Complete history of all changes

§deleted_columns: BTreeMap<String, SchemaField>

Deleted columns (for recovery)

§type_conversions: HashMap<String, TypeConversionRule>

Type conversion registry

Implementations§

Source§

impl KoreSchema

Source

pub fn new(initial_columns: Vec<KColumn>) -> Self

Create a new schema with initial columns

Source

pub fn get_column(&self, name: &str) -> Option<&SchemaField>

Get a column by name (handles aliases)

Source

pub fn add_column( &mut self, name: String, column_type: KType, nullable: bool, default_value: Option<KVal>, author: String, reason: String, ) -> Result<(), String>

Add a new column

Source

pub fn remove_column( &mut self, name: &str, author: String, reason: String, ) -> Result<(), String>

Remove a column (lazy deletion - mark as deleted)

Source

pub fn rename_column( &mut self, old_name: &str, new_name: &str, author: String, reason: String, ) -> Result<(), String>

Rename a column (maintains backward compatibility via aliases)

Source

pub fn change_type( &mut self, column_name: &str, new_type: KType, conversion_rule: TypeConversionRule, author: String, reason: String, ) -> Result<(), String>

Evolve a column’s type

Source

pub fn set_nullable( &mut self, column_name: &str, nullable: bool, author: String, reason: String, ) -> Result<(), String>

Modify column nullability

Source

pub fn active_columns(&self) -> Vec<&SchemaField>

Get all active (non-deleted) columns

Source

pub fn num_active_columns(&self) -> usize

Get number of active columns

Source

pub fn has_column(&self, name: &str) -> bool

Check if a column exists and is active

Source

pub fn get_history(&self) -> &[SchemaHistoryEntry]

Get the history of changes

Source

pub fn get_schema_at_version( &self, target_version: SchemaVersion, ) -> Result<KoreSchema, String>

Get schema at a specific version (reconstruct from history)

Source

pub fn is_backward_compatible(&self) -> bool

Validate backward compatibility: can old readers read new data?

Source

pub fn is_forward_compatible(&self) -> bool

Validate forward compatibility: can new readers read old data?

Trait Implementations§

Source§

impl Clone for KoreSchema

Source§

fn clone(&self) -> KoreSchema

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§

impl Debug for KoreSchema

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.