Skip to main content

AbiPolicy

Enum AbiPolicy 

Source
#[non_exhaustive]
pub enum AbiPolicy { Strict, Warn, AllowUnknownEngine, Trust, }
Expand description

How init_extension should react to the ABI layout check.

#[non_exhaustive]: a future release may add a policy, so a match outside quack-rs needs a wildcard arm.

ⓘ
use quack_rs::abi::AbiPolicy;

fn checks(policy: AbiPolicy) -> bool {
    match policy {
        AbiPolicy::Strict | AbiPolicy::Warn | AbiPolicy::AllowUnknownEngine => true,
        AbiPolicy::Trust => false,
        // error[E0004]: a wildcard arm is required
    }
}

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Strict

Refuse to load unless the layout is verified compatible.

This is the default. It converts what would otherwise be silent mis-dispatch into a clear LOAD error naming the exact remedy.

§

Warn

Perform the check and, on failure, print the diagnostic to stderr but continue loading.

Note the channel: this cannot use access.set_error, because DuckDB’s loader throws whenever an extension called set_error — regardless of what the entry point returned — which would make Warn behave exactly like Strict. The C extension API has no non-fatal diagnostic channel, so the message goes to stderr.

Use this when the crate is built with duckdb-1-5 but the extension provably calls only stable-region wrappers, and you want the mismatch visible without failing the load. Calling into the unstable region after a failed check is undefined behaviour — Warn does not make it safe, it only makes it loud.

§

AllowUnknownEngine

Refuse a layout the table says is different, but allow a DuckDB release the table has no entry for.

This is the forward-compatibility knob. It still catches the dangerous, verifiable case — an extension built against v1.5.0 meeting v1.5.5 — while letting the extension load on a release newer than this build of quack-rs knows about.

Prefer setting QUACK_RS_TARGET_DUCKDB_VERSION instead, which turns the same situation into a positive match rather than a suspended judgement. Reach for this only when the build cannot set that variable.

The risk is real and asymmetric: DuckDB changed the unstable region in every minor release from v1.3.0 on, and in the v1.5.2 patch release, so an unknown version is more likely to differ than to match. Under this policy, an extension that calls into the unstable region on a release it was not built for is undefined behaviour. This is not hypothetical: before DuckDB v1.4.5 was added to the table, a v1.5.5 build loaded into v1.4.5 under this policy and segfaulted on its first unstable-region call. The refusal message for an unknown engine therefore never suggests this policy.

§

Trust

Skip the check entirely.

Appropriate when the binary is stamped C_STRUCT_UNSTABLE, because DuckDB then refuses to load it into any release other than the one it was built for — making the runtime check redundant. Also appropriate when the duckdb-1-5 feature is enabled but the extension provably calls only stable-region wrappers.

Trait Implementations§

Source§

impl Clone for AbiPolicy

Source§

fn clone(&self) -> AbiPolicy

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 Copy for AbiPolicy

Source§

impl Debug for AbiPolicy

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for AbiPolicy

Source§

fn default() -> AbiPolicy

Returns the “default value” for a type. Read more
Source§

impl Eq for AbiPolicy

Source§

impl From<AbiPolicy> for EntryPointOptions

Source§

fn from(policy: AbiPolicy) -> Self

policy, with the default Registration mode.

Source§

impl PartialEq for AbiPolicy

Source§

fn eq(&self, other: &AbiPolicy) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for AbiPolicy

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.