#[non_exhaustive]pub struct TxOptions {
pub read_only: bool,
pub isolation: Option<IsolationLevel>,
pub run_pre_request: bool,
}Expand description
How AppState::begin_as_with begins a transaction.
#[non_exhaustive], so a knob can be added in a minor release: start from
the default and change what should differ.
use postrust_core::IsolationLevel;
use postrust_server::TxOptions;
let options = TxOptions::default()
.read_only(true)
.isolation(IsolationLevel::RepeatableRead);
assert!(options.read_only && options.run_pre_request);Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.read_only: boolWhether the transaction is read-only, which PostgreSQL enforces for
everything the transaction reaches – a volatile function, a trigger.
A write is refused with 25006, answered 405 as REST answers it.
Off by default.
isolation: Option<IsolationLevel>The isolation level, over the role’s (role_settings) and the
server’s (PGRST_DB_TX_ISOLATION). None, the default, leaves the
choice to them, as REST does.
run_pre_request: boolWhether to call db_pre_request, where one is configured. On by
default, as it is for every REST request: it is commonly where a
deployment refuses a caller, and a route that skips it skips that.
Implementations§
Source§impl TxOptions
impl TxOptions
Sourcepub fn read_only(self, read_only: bool) -> Self
pub fn read_only(self, read_only: bool) -> Self
With read_only set. See TxOptions::read_only.
Sourcepub fn isolation(self, isolation: IsolationLevel) -> Self
pub fn isolation(self, isolation: IsolationLevel) -> Self
At isolation, whatever the configuration says.
Sourcepub fn run_pre_request(self, run_pre_request: bool) -> Self
pub fn run_pre_request(self, run_pre_request: bool) -> Self
With run_pre_request set.
Trait Implementations§
impl Eq for TxOptions
impl StructuralPartialEq for TxOptions
Auto Trait Implementations§
impl Freeze for TxOptions
impl RefUnwindSafe for TxOptions
impl Send for TxOptions
impl Sync for TxOptions
impl Unpin for TxOptions
impl UnsafeUnpin for TxOptions
impl UnwindSafe for TxOptions
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more