pub struct QueryContext { /* private fields */ }Expand description
Data associated with a query.
Implementations§
Source§impl QueryContext
impl QueryContext
Sourcepub fn add_argument(&mut self, value: impl ToString)
pub fn add_argument(&mut self, value: impl ToString)
Adds an argument to the list of query arguments.
Sourcepub fn append_arguments(&mut self, arguments: &mut Vec<String>)
pub fn append_arguments(&mut self, arguments: &mut Vec<String>)
Appends the query arguments.
Sourcepub fn set_last_insert_id(&mut self, last_insert_id: i64)
pub fn set_last_insert_id(&mut self, last_insert_id: i64)
Sets the last insert ID.
Sourcepub fn set_query_result(
&mut self,
rows_affected: impl Into<Option<u64>>,
success: bool,
)
pub fn set_query_result( &mut self, rows_affected: impl Into<Option<u64>>, success: bool, )
Sets the query result.
Sourcepub fn model_name(&self) -> &'static str
pub fn model_name(&self) -> &'static str
Returns the model name.
Sourcepub fn start_time(&self) -> Instant
pub fn start_time(&self) -> Instant
Returns the start time.
Sourcepub fn last_insert_id(&self) -> Option<i64>
pub fn last_insert_id(&self) -> Option<i64>
Returns the last insert ID.
Sourcepub fn rows_affected(&self) -> Option<u64>
pub fn rows_affected(&self) -> Option<u64>
Returns the number of rows affected.
Sourcepub fn is_cancelled(&self) -> bool
pub fn is_cancelled(&self) -> bool
Returns true if the query execution is cancelled.
Sourcepub fn is_success(&self) -> bool
pub fn is_success(&self) -> bool
Returns true if the query execution is successful.
Sourcepub fn format_arguments(&self) -> Option<String>
pub fn format_arguments(&self) -> Option<String>
Formats the query arguments as a String if they exist.
Sourcepub fn record_error(&self, message: impl AsRef<str>)
pub fn record_error(&self, message: impl AsRef<str>)
Records an error message for the query.
Sourcepub fn emit_metrics(&self, action: impl Into<SharedString>)
Available on crate feature metrics only.
pub fn emit_metrics(&self, action: impl Into<SharedString>)
metrics only.Emits the metrics for the query.
Trait Implementations§
Source§impl Clone for QueryContext
impl Clone for QueryContext
Source§fn clone(&self) -> QueryContext
fn clone(&self) -> QueryContext
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for QueryContext
impl RefUnwindSafe for QueryContext
impl Send for QueryContext
impl Sync for QueryContext
impl Unpin for QueryContext
impl UnwindSafe for QueryContext
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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