Skip to main content

DbConfig

Struct DbConfig 

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

RAII wrapper for a duckdb_config handle.

Configuration options are set via set and consumed by passing as_raw to duckdb_open_ext. The handle is destroyed automatically when DbConfig is dropped.

Implementations§

Source§

impl DbConfig

Source

pub fn new() -> Result<Self, ExtensionError>

Creates a new, empty DuckDB configuration object.

§Errors

Returns ExtensionError if DuckDB fails to allocate the config (which is extremely rare in practice).

Source

pub fn set(self, name: &str, value: &str) -> Result<Self, ExtensionError>

Sets a single configuration option.

Common options include "access_mode" ("READ_ONLY" / "READ_WRITE"), "threads" (number of CPU threads), and "memory_limit" (e.g. "1GB"). Use DbConfig::flag_count / DbConfig::get_flag to enumerate all available options at runtime.

§Unknown option names are accepted here

duckdb_set_config does not reject a name it does not know: it stores it among the config’s unrecognised options (an extension loaded later may define it), and the database open that uses this config is what fails, with unrecognized configuration parameter. Check a name against flag_count / get_flag first if you need to catch a typo at this point.

§Errors

Returns ExtensionError if name or value contain interior null bytes, or if DuckDB rejects the value for an option it recognises (for example a non-numeric "threads").

Source

pub fn flag_count() -> usize

Returns the total number of available configuration flags.

Use this together with get_flag to enumerate all configuration options that DuckDB accepts.

Source

pub fn get_flag(index: usize) -> Result<(String, String), ExtensionError>

Returns the name and the second string DuckDB reports for the configuration flag at index.

For a core option or one of its aliases the second string is the option’s description. For a setting that belongs to an extension (s3_region, …) it is the extension’s name ("httpfs"): the third branch of duckdb_get_config_flag reports entry->extension there, not a description.

index must be less than flag_count().

§Errors

Returns ExtensionError if index is out of range or DuckDB fails to retrieve the flag information.

Source

pub const fn as_raw(&self) -> duckdb_config

Returns the underlying duckdb_config handle.

Pass this to duckdb_open_ext to open a database with these settings.

The handle remains owned by DbConfig; do not call duckdb_destroy_config on the returned value.

Trait Implementations§

Source§

impl Debug for DbConfig

Source§

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

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

impl Drop for DbConfig

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. 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> 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, 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.