Builder

Struct Builder 

Source
pub struct Builder { /* private fields */ }
Available on crate feature sqlsrv only.
Expand description

Builder for constructing a ConnPool object.

Implementations§

Source§

impl Builder

This impl block contains no items.

Internal methods.

Source§

impl Builder

Source

pub fn new(schmgr: Box<dyn SchemaMgr>) -> Builder

Create a new Builder for constructing a ConnPool object.

Default to not run a full vacuum of the database on initialization and create 2 read-only connections for the pool. No workers thread pool will be used.

Source

pub const fn init_vacuum(self) -> Builder

Trigger a full vacuum when initializing the connection pool.

Operates on an owned Builder object.

Source

pub const fn init_vacuum_r(&mut self) -> &mut Builder

Trigger a full vacuum when initializing the connection pool.

Operates on a borrowed Builder object.

Source

pub const fn max_readers(self, n: usize) -> Builder

Set maximum number of readers in the connection pool.

Operates on an owned Builder object.

Source

pub const fn max_readers_r(&mut self, n: usize) -> &mut Builder

Set maximum number of readers in the connection pool.

Operates on a borrowed Builder object.

Source

pub fn hook(self, hook: Arc<dyn Hook + Send + Sync>) -> Builder

Request that a “raw” update hook be added to the writer connection.

Operates on an owned Builder object.

Source

pub fn hook_r(&mut self, hook: Arc<dyn Hook + Send + Sync>) -> &mut Builder

Request that a “raw” update hook be added to the writer connection.

Operates on a borrowed Builder object.

Source

pub const fn incremental_autoclean( self, dirt_watermark: usize, npages: Option<NonZero<usize>>, ) -> Builder

Enable incremental autovacuum.

dirt_watermark is used to set what amount of “dirt” is required in order to trigger an autoclean. nfree is the number of blocks in the freelists to process each time the autoclean is run.

Source

pub fn reg_scalar_fn<F>(self, r: RegOn<F>) -> Builder
where F: Fn(&Connection) -> Result<(), Error> + Send + Sync + 'static,

Add a callback to register one or more scalar SQL functions.

The closure should be wrapped in a RegOn::RO() if the function should only be registered on read-only connections. RegOn::RW() is used to register the function on the read/write connection. Use RegOn::Both() to register in both read-only and the read/write connection.

Source

pub fn reg_scalar_fn_r<F>(&mut self, r: RegOn<F>) -> &mut Builder
where F: Fn(&Connection) -> Result<(), Error> + Send + Sync + 'static,

Add a callback to register one or more scalar SQL functions.

This is the same as Builder::reg_scalar_fn(), but it operates on &mut Builder rather than passing ownership.

Source

pub fn thread_pool(self, tpool: Arc<ThreadPool>) -> Builder

Source

pub fn thread_pool_r(&mut self, tpool: Arc<ThreadPool>) -> &mut Builder

Source

pub fn build<P>(self, fname: P) -> Result<ConnPool, Error>
where P: AsRef<Path>,

Construct a connection pool.

§Errors

Error::Sqlite will be returned if a database error occurred.

Source

pub fn build_with_changelog_hook<P, D, T>( self, fname: P, hook: Box<dyn ChangeLogHook<Table = T, Database = D> + Send>, ) -> Result<ConnPool, Error>
where P: AsRef<Path>, D: FromStr + Send + 'static, T: FromStr + Send + 'static,

Construct a connection pool.

Same as Builder::build(), but register a change log callback on the writer as well.

This method should not be called if the application has requested to add a raw update hook.

§Errors

Error::Sqlite is returned for database errors.

§Panics

This method will panic if a hook has been added to the Builder.

Auto Trait Implementations§

§

impl Freeze for Builder

§

impl !RefUnwindSafe for Builder

§

impl !Send for Builder

§

impl !Sync for Builder

§

impl Unpin for Builder

§

impl !UnwindSafe for Builder

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.
Source§

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

Source§

fn vzip(self) -> V