pub struct Ctx(/* private fields */);Expand description
会话上下文。此处 clone 的成本很低
Implementations§
Source§impl Ctx
impl Ctx
Sourcepub fn try_new(
payload: CtxPayload,
req_time: Option<DateTime<FixedOffset>>,
req_id: Option<String>,
) -> Result<Self, CtxError>
pub fn try_new( payload: CtxPayload, req_time: Option<DateTime<FixedOffset>>, req_id: Option<String>, ) -> Result<Self, CtxError>
Create a new context
pub fn new_root() -> Self
pub fn new_super_admin() -> Self
pub fn get_user_id(&self) -> Option<i64>
pub fn user_id(&self) -> i64
pub fn get_tenant_id(&self) -> Option<i64>
pub fn tenant_id(&self) -> i64
pub fn req_time(&self) -> &DateTime<FixedOffset>
pub fn req_epoch_secs(&self) -> i64
pub fn req_epoch_millis(&self) -> i64
pub fn req_id(&self) -> &str
pub fn expires_at(&self) -> Option<DateTime<Utc>>
pub fn payload(&self) -> &CtxPayload
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Ctx
impl<'de> Deserialize<'de> for Ctx
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 Ctx
impl RefUnwindSafe for Ctx
impl Send for Ctx
impl Sync for Ctx
impl Unpin for Ctx
impl UnsafeUnpin for Ctx
impl UnwindSafe for Ctx
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