Skip to main content

DatabaseBuilderReservation

Struct DatabaseBuilderReservation 

Source
pub struct DatabaseBuilderReservation { /* private fields */ }
Expand description

An atomically claimed, identity-bound pathname for building a replacement database image.

Two-phase create protocol. Phase 1 (Connection::reserve_schema_only_builder_target) claims the pathname with create-new/no-follow semantics and retains the descriptor that created it. Phase 2 (Connection::initialize_reserved_schema_only_builder) revalidates and hands back a writable builder connection bound to Self::identity.

Keeping this value alive for the whole build is not bookkeeping — it is the guarantee. Holding the creating descriptor open prevents the inode being recycled, so every later check runs against a stable identity rather than a re-resolved pathname, which is what closes the create-then-swap window. A caller must therefore hold the reservation across construction and finish with Self::revalidate_final_target, not drop it after phase 2.

Every supported native platform rechecks the retained and pathname-opened handles against the reserved identity. Unix additionally requires each handle’s link count to remain exactly one. Windows has no corresponding portable metadata check here, so this type does not promise link-count enforcement there.

Existing paths are never opened, truncated, replaced, or unlinked by reservation: the builder can only ever write to a file it created.

Implementations§

Source§

impl DatabaseBuilderReservation

Source

pub fn path(&self) -> &Path

Absolute, stable pathname atomically reserved for the builder.

Source

pub const fn identity(&self) -> FileIdentity

Stable identity of the retained create-new descriptor.

Source

pub const fn write_set_page_limit(&self) -> usize

The validated write-set page ceiling recorded for this build.

Source

pub const fn write_set_limit_enforced(&self) -> bool

Whether the recorded write-set ceiling is enforced by the engine during the build.

true: the ceiling is installed on the builder’s pager and checked in SimpleTransaction::write_page / write_page_data before a new page enters the write set, so an over-budget build fails with a typed FrankenError::OutOfRange at the moment of excess rather than at commit. Distinct from page_buffer_max, which caps resident buffers — a memory bound, not a bound on how much of the database is rewritten.

The ceiling covers caller-staged pages; commit-time engine metadata (page 1, freelist serialization) is excluded and is not caller-attributable.

Source

pub fn revalidate_final_target(&self, expected_len: Option<u64>) -> Result<()>

Fail-closed final validation of the retained create-new authority.

Call after the private build and immediately before releasing the reservation. Proves, twice over, that the retained descriptor and the final no-follow pathname resolve to the same regular file of the expected exact length. Unix additionally refuses any link count other than one; Windows preserves the identity/path checks but does not expose equivalent link-count enforcement through this contract.

§Errors

FrankenError::CannotOpen on any mismatch, and FrankenError::Unsupported on non-native builds, which refuse rather than skipping the check.

Trait Implementations§

Source§

impl Debug for DatabaseBuilderReservation

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, _span: NoopSpan) -> Self

Instruments this future with a span (no-op when disabled).
Source§

fn in_current_span(self) -> Self

Instruments this future with the current span (no-op when disabled).
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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more