pub struct BranchContext { /* private fields */ }Expand description
Branch context for data virtualization.
Determines which branch a request targets. When a branch is active, the gateway applies Copy-on-Write semantics:
- Reads: main rows UNION branch overlay (overlay wins on PK conflict)
- Writes: inserted/updated rows go to
_qail_branch_rowsoverlay - Deletes: a tombstone marker is added to the overlay
Implementations§
Source§impl BranchContext
impl BranchContext
Sourcepub const MAX_NAME_LEN: usize = 64
pub const MAX_NAME_LEN: usize = 64
Maximum branch name length.
Sourcepub fn branch(name: &str) -> Self
pub fn branch(name: &str) -> Self
Create a context targeting a named branch.
§Panics
Panics if the branch name is invalid. Use try_branch for fallible creation.
Sourcepub fn try_branch(name: &str) -> Option<Self>
pub fn try_branch(name: &str) -> Option<Self>
Try to create a branch context, returning None if the name is invalid.
Sourcepub fn parse_header(value: Option<&str>) -> Result<Self, String>
pub fn parse_header(value: Option<&str>) -> Result<Self, String>
Parse an optional branch header value into a BranchContext.
Rules:
None, empty string, andmain(case-insensitive) map to main.- Any other value must pass
Self::is_valid_name.
Sourcepub fn from_header(value: Option<&str>) -> Result<Self, String>
pub fn from_header(value: Option<&str>) -> Result<Self, String>
Create from an optional branch name (None = main).
Sourcepub fn is_valid_name(name: &str) -> bool
pub fn is_valid_name(name: &str) -> bool
Validate a branch name.
Rules:
- 1 to 64 characters
- Only alphanumeric, hyphens (
-), underscores (_), and dots (.) - Must not start with
.or-
Sourcepub fn has_branch(&self) -> bool
pub fn has_branch(&self) -> bool
Returns true if this is a named branch (not main).
Sourcepub fn branch_name(&self) -> Option<&str>
pub fn branch_name(&self) -> Option<&str>
Get the branch name, if any.
Trait Implementations§
Source§impl Clone for BranchContext
impl Clone for BranchContext
Source§fn clone(&self) -> BranchContext
fn clone(&self) -> BranchContext
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for BranchContext
impl Debug for BranchContext
Source§impl Display for BranchContext
impl Display for BranchContext
impl Eq for BranchContext
Source§impl PartialEq for BranchContext
impl PartialEq for BranchContext
impl StructuralPartialEq for BranchContext
Auto Trait Implementations§
impl Freeze for BranchContext
impl RefUnwindSafe for BranchContext
impl Send for BranchContext
impl Sync for BranchContext
impl Unpin for BranchContext
impl UnsafeUnpin for BranchContext
impl UnwindSafe for BranchContext
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