pub struct Session { /* private fields */ }Expand description
One server-side session.
Debug shows the id prefix, the user, the attribute keys and the timestamps, never the
attribute values (they can hold OIDC tokens or a CSRF secret).
Implementations§
Source§impl Session
impl Session
Sourcepub fn from_parts(
id: SessionId,
user_id: impl Into<String>,
attrs: BTreeMap<String, String>,
created_at: UtcDateTime,
last_seen_at: UtcDateTime,
idle_expires_at: UtcDateTime,
absolute_expires_at: UtcDateTime,
) -> Self
pub fn from_parts( id: SessionId, user_id: impl Into<String>, attrs: BTreeMap<String, String>, created_at: UtcDateTime, last_seen_at: UtcDateTime, idle_expires_at: UtcDateTime, absolute_expires_at: UtcDateTime, ) -> Self
A session record as a store reads it back (stores call this; handlers get sessions from
Sessions).
Sourcepub fn attrs(&self) -> &BTreeMap<String, String>
pub fn attrs(&self) -> &BTreeMap<String, String>
String attributes (tenant, roles, CSRF secret, …).
Sourcepub fn set_attr(
&mut self,
key: impl Into<String>,
value: impl Into<String>,
) -> &mut Self
pub fn set_attr( &mut self, key: impl Into<String>, value: impl Into<String>, ) -> &mut Self
Set an attribute; persist it with Sessions::save.
Sourcepub fn remove_attr(&mut self, key: &str) -> Option<String>
pub fn remove_attr(&mut self, key: &str) -> Option<String>
Remove an attribute; persist it with Sessions::save.
Sourcepub fn created_at(&self) -> UtcDateTime
pub fn created_at(&self) -> UtcDateTime
When the session was created (at login).
Sourcepub fn last_seen_at(&self) -> UtcDateTime
pub fn last_seen_at(&self) -> UtcDateTime
When the session was last used (to within SessionConfig::touch_interval).
Sourcepub fn idle_expires_at(&self) -> UtcDateTime
pub fn idle_expires_at(&self) -> UtcDateTime
When the session ends if it is not used again (idle timeout).
Sourcepub fn absolute_expires_at(&self) -> UtcDateTime
pub fn absolute_expires_at(&self) -> UtcDateTime
When the session ends however much it is used (absolute timeout).
Sourcepub fn expires_at(&self) -> UtcDateTime
pub fn expires_at(&self) -> UtcDateTime
The earlier of the two expiries.
Sourcepub fn is_expired(&self, now: UtcDateTime) -> bool
pub fn is_expired(&self, now: UtcDateTime) -> bool
true once now reached either expiry.
Trait Implementations§
impl Eq for Session
impl StructuralPartialEq for Session
Auto Trait Implementations§
impl Freeze for Session
impl RefUnwindSafe for Session
impl Send for Session
impl Sync for Session
impl Unpin for Session
impl UnsafeUnpin for Session
impl UnwindSafe for Session
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Equal for T
impl<T> Equal for T
Source§fn effect_equals(&self, other: &Self) -> bool
fn effect_equals(&self, other: &Self) -> bool
self and other are structurally equal (defaults to PartialEq::eq).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.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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 moreSource§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§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();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§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();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§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();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§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();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
Source§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);Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<P> PolicyExt for P
impl<P> PolicyExt for P
Source§fn and<P>(self, other: P) -> And<Self, P>
fn and<P>(self, other: P) -> And<Self, P>
other runs only when self allows.Source§fn or<P>(self, other: P) -> Or<Self, P>
fn or<P>(self, other: P) -> Or<Self, P>
other runs only when self denies (its denial is kept).Source§fn negate(self, reason: impl Into<String>) -> Not<Self>
fn negate(self, reason: impl Into<String>) -> Not<Self>
self denies; denies with reason when it allows.Source§fn dangerous_cross_tenant(self, reason: impl Into<String>) -> CrossTenant<Self>
fn dangerous_cross_tenant(self, reason: impl Into<String>) -> CrossTenant<Self>
check_with / authorize_with, it decides on a Tenanted resource
for principals of any tenant. reason says who needs that (support tooling, a platform
operator) and is kept on the policy for review. Read more