pub struct ConnectionConfiguration { /* private fields */ }Expand description
Combines a couple of settings that influence the runtime behavior of a connection.
Example
let config = ConnectionConfiguration::default()
.with_lob_read_length(1_000_000)
.with_max_buffer_size(1_000_000);
let connection = Connection::with_configuration(db_url, &config).await?;Implementations§
source§impl ConnectionConfiguration
impl ConnectionConfiguration
sourcepub const DEFAULT_FETCH_SIZE: u32 = 10_000u32
pub const DEFAULT_FETCH_SIZE: u32 = 10_000u32
Default value for the number of resultset lines that are fetched with a single FETCH roundtrip.
The value can be changed at runtime with Connection::set_fetch_size().
sourcepub const DEFAULT_LOB_READ_LENGTH: u32 = 203_776u32
pub const DEFAULT_LOB_READ_LENGTH: u32 = 203_776u32
Default value for the number of bytes (for BLOBS and CLOBS) or 1-2-3-byte sequences (for NCLOBS) that are fetched in a single LOB READ roundtrip.
The value can be changed at runtime with Connection::set_lob_read_length().
sourcepub const DEFAULT_LOB_WRITE_LENGTH: u32 = 203_776u32
pub const DEFAULT_LOB_WRITE_LENGTH: u32 = 203_776u32
Default value for the number of bytes that are written in a single LOB WRITE roundtrip.
The value can be changed at runtime with Connection::set_lob_write_length().
sourcepub const MIN_BUFFER_SIZE: usize = 10_240usize
pub const MIN_BUFFER_SIZE: usize = 10_240usize
Minimal buffer size.
Each connection maintains its own re-use buffer into which each outgoing request and each incoming reply is serialized.
The buffer is automatically increased when necessary to cope with large requests or replies. The default minimum buffer size is chosen to be sufficient for many usecases, to avoid buffer increases.
sourcepub const DEFAULT_MAX_BUFFER_SIZE: usize = 204_800usize
pub const DEFAULT_MAX_BUFFER_SIZE: usize = 204_800usize
Default value for the maximum buffer size.
A large request or response will enforce a corresponding enlargement of the connection’s buffer. Oversized buffers are not kept for the whole lifetime of the connection, but shrinked after use to the configured maximum buffer size.
The value can be changed at runtime with Connection::set_max_buffer_size().
sourcepub const DEFAULT_MIN_COMPRESSION_SIZE: usize = 5_120usize
pub const DEFAULT_MIN_COMPRESSION_SIZE: usize = 5_120usize
Default value for the threshold size above which requests will be compressed.
sourcepub fn is_auto_commit(&self) -> bool
pub fn is_auto_commit(&self) -> bool
Returns whether the connection uses auto-commit.
sourcepub fn set_auto_commit(&mut self, ac: bool)
pub fn set_auto_commit(&mut self, ac: bool)
Defines whether the connection should use auto-commit.
sourcepub fn with_auto_commit(self, ac: bool) -> ConnectionConfiguration
pub fn with_auto_commit(self, ac: bool) -> ConnectionConfiguration
Builder-method for defining whether the connection should use auto-commit.
sourcepub fn fetch_size(&self) -> u32
pub fn fetch_size(&self) -> u32
Returns the connection’s fetch size.
sourcepub fn set_fetch_size(&mut self, fetch_size: u32)
pub fn set_fetch_size(&mut self, fetch_size: u32)
Sets the connection’s fetch size.
sourcepub fn with_fetch_size(self, fetch_size: u32) -> ConnectionConfiguration
pub fn with_fetch_size(self, fetch_size: u32) -> ConnectionConfiguration
Builder-method for setting the connection’s fetch size.
sourcepub fn lob_read_length(&self) -> u32
pub fn lob_read_length(&self) -> u32
Returns the connection’s lob read length.
sourcepub fn set_lob_read_length(&mut self, lob_read_length: u32)
pub fn set_lob_read_length(&mut self, lob_read_length: u32)
Sets the connection’s lob read length.
sourcepub fn with_lob_read_length(
self,
lob_read_length: u32
) -> ConnectionConfiguration
pub fn with_lob_read_length( self, lob_read_length: u32 ) -> ConnectionConfiguration
Builder-method for setting the connection’s lob read length.
sourcepub fn lob_write_length(&self) -> u32
pub fn lob_write_length(&self) -> u32
Returns the connection’s lob write length.
sourcepub fn set_lob_write_length(&mut self, lob_write_length: u32)
pub fn set_lob_write_length(&mut self, lob_write_length: u32)
Sets the connection’s lob write length.
sourcepub fn with_lob_write_length(
self,
lob_write_length: u32
) -> ConnectionConfiguration
pub fn with_lob_write_length( self, lob_write_length: u32 ) -> ConnectionConfiguration
Builder-method for setting the connection’s lob write length.
sourcepub fn max_buffer_size(&self) -> usize
pub fn max_buffer_size(&self) -> usize
Returns the connection’s max buffer size.
See also [ConnectionConfiguration::DEFAULT_MIN_BUFFER_SIZE] and
ConnectionConfiguration::DEFAULT_MAX_BUFFER_SIZE.
sourcepub fn set_max_buffer_size(&mut self, max_buffer_size: usize)
pub fn set_max_buffer_size(&mut self, max_buffer_size: usize)
Sets the connection’s max buffer size.
See also [ConnectionConfiguration::DEFAULT_MIN_BUFFER_SIZE] and
ConnectionConfiguration::DEFAULT_MAX_BUFFER_SIZE.
sourcepub fn with_max_buffer_size(
self,
max_buffer_size: usize
) -> ConnectionConfiguration
pub fn with_max_buffer_size( self, max_buffer_size: usize ) -> ConnectionConfiguration
Builder-method for setting the connection’s max buffer size.
See also [ConnectionConfiguration::DEFAULT_MIN_BUFFER_SIZE] and
ConnectionConfiguration::DEFAULT_MAX_BUFFER_SIZE.
sourcepub fn min_compression_size(&self) -> usize
pub fn min_compression_size(&self) -> usize
Returns the connection’s min compression size.
sourcepub fn set_min_compression_size(&mut self, min_compression_size: usize)
pub fn set_min_compression_size(&mut self, min_compression_size: usize)
Sets the connection’s min compression size.
sourcepub fn with_min_compression_size(
self,
min_compression_size: usize
) -> ConnectionConfiguration
pub fn with_min_compression_size( self, min_compression_size: usize ) -> ConnectionConfiguration
Builder-method for setting the connection’s min compression size.
Trait Implementations§
source§impl Clone for ConnectionConfiguration
impl Clone for ConnectionConfiguration
source§fn clone(&self) -> ConnectionConfiguration
fn clone(&self) -> ConnectionConfiguration
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Debug for ConnectionConfiguration
impl Debug for ConnectionConfiguration
source§impl Default for ConnectionConfiguration
impl Default for ConnectionConfiguration
source§fn default() -> ConnectionConfiguration
fn default() -> ConnectionConfiguration
Auto Trait Implementations§
impl RefUnwindSafe for ConnectionConfiguration
impl Send for ConnectionConfiguration
impl Sync for ConnectionConfiguration
impl Unpin for ConnectionConfiguration
impl UnwindSafe for ConnectionConfiguration
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> IntoCollection<T> for T
impl<T> IntoCollection<T> for T
§fn into_collection<A>(self) -> SmallVec<A>where
A: Array<Item = T>,
fn into_collection<A>(self) -> SmallVec<A>where
A: Array<Item = T>,
self into a collection.fn mapped<U, F, A>(self, f: F) -> SmallVec<A>where
F: FnMut(T) -> U,
A: Array<Item = U>,
§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling [Attribute] value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi [Quirk] value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the [Condition] value
applies. Replaces any previous condition.
See the crate level docs for more details.
Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);