pub struct SchemaRegistry { /* private fields */ }Expand description
Registry mapping key prefixes to table names.
Thread-safe for concurrent reads with occasional writes. Prefixes are matched using longest-prefix-first semantics.
Implementations§
Source§impl SchemaRegistry
impl SchemaRegistry
Sourcepub fn bypass() -> Self
pub fn bypass() -> Self
Create a registry that bypasses all routing (returns default table).
Use this for SQLite where table partitioning has no benefit.
Sourcepub fn register(&self, prefix: &str, table_name: &str)
pub fn register(&self, prefix: &str, table_name: &str)
Register a prefix to route to a specific table.
Multiple prefixes can map to the same table. Longer prefixes take precedence over shorter ones.
§Arguments
prefix- Key prefix to match (e.g., “view:users:”)table_name- Target table name (e.g., “users_items”)
Sourcepub fn unregister(&self, prefix: &str) -> bool
pub fn unregister(&self, prefix: &str) -> bool
Unregister a prefix.
Returns true if the prefix was found and removed.
Sourcepub fn table_for_key(&self, key: &str) -> &'static str
pub fn table_for_key(&self, key: &str) -> &'static str
Get the table name for a given key.
Uses longest-prefix-first matching. Returns DEFAULT_TABLE if no prefix matches
or if bypass mode is enabled.
Sourcepub fn prefixes_for_table(&self, table_name: &str) -> Vec<String>
pub fn prefixes_for_table(&self, table_name: &str) -> Vec<String>
Get all registered prefixes for a table.
Trait Implementations§
Source§impl Debug for SchemaRegistry
impl Debug for SchemaRegistry
Auto Trait Implementations§
impl !Freeze for SchemaRegistry
impl !RefUnwindSafe for SchemaRegistry
impl Send for SchemaRegistry
impl Sync for SchemaRegistry
impl Unpin for SchemaRegistry
impl UnwindSafe for SchemaRegistry
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more