pub struct DbContext {
pub user_id: Option<Uuid>,
pub request_id: Option<String>,
pub session_id: Option<String>,
pub ip_address: Option<String>,
pub user_agent: Option<String>,
pub custom_fields: HashMap<String, String>,
}Expand description
Context for database operations
Fields§
§user_id: Option<Uuid>User ID (if applicable)
request_id: Option<String>Request ID for correlation
session_id: Option<String>Session ID
ip_address: Option<String>IP address
user_agent: Option<String>User agent
custom_fields: HashMap<String, String>Additional custom fields
Implementations§
Source§impl DbContext
impl DbContext
Sourcepub fn with_user_id(self, user_id: Uuid) -> Self
pub fn with_user_id(self, user_id: Uuid) -> Self
Create a new context with user ID
Sourcepub fn with_request_id(self, request_id: String) -> Self
pub fn with_request_id(self, request_id: String) -> Self
Add request ID
Sourcepub fn with_session_id(self, session_id: String) -> Self
pub fn with_session_id(self, session_id: String) -> Self
Add session ID
Sourcepub fn with_ip_address(self, ip_address: String) -> Self
pub fn with_ip_address(self, ip_address: String) -> Self
Add IP address
Sourcepub fn with_user_agent(self, user_agent: String) -> Self
pub fn with_user_agent(self, user_agent: String) -> Self
Add user agent
Trait Implementations§
Source§impl<'de> Deserialize<'de> for DbContext
impl<'de> Deserialize<'de> for DbContext
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for DbContext
impl RefUnwindSafe for DbContext
impl Send for DbContext
impl Sync for DbContext
impl Unpin for DbContext
impl UnwindSafe for DbContext
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