StpUtil

Struct StpUtil 

Source
pub struct StpUtil;
Expand description

StpUtil - 权限认证工具类

提供便捷的认证和授权操作方法,类似于 Java 版 sa-token 的 StpUtil

Implementations§

Source§

impl StpUtil

Source

pub fn init_manager(manager: SaTokenManager)

初始化全局 SaTokenManager(应用启动时调用一次)

§示例
let manager = SaTokenConfig::builder()
    .storage(Arc::new(MemoryStorage::new()))
    .build();
StpUtil::init_manager(manager);
Source

pub fn event_bus() -> &'static SaTokenEventBus

获取事件总线,用于注册监听器

§示例
use sa_token_core::{StpUtil, SaTokenListener};
use async_trait::async_trait;
 
struct MyListener;
 
#[async_trait]
impl SaTokenListener for MyListener {
    async fn on_login(&self, login_id: &str, token: &str, login_type: &str) {
        println!("用户 {} 登录了", login_id);
    }
}
 
// 注册监听器
StpUtil::event_bus().register(Arc::new(MyListener)).await;
Source

pub fn register_listener(listener: Arc<dyn SaTokenListener>)

注册事件监听器(便捷方法)

§示例
StpUtil::register_listener(Arc::new(MyListener)).await;
Source

pub async fn login(login_id: impl LoginId) -> Result<TokenValue, SaTokenError>

会话登录

§示例
// 支持字符串 ID
let token = StpUtil::login("user_123").await?;
 
// 支持数字 ID
let token = StpUtil::login(10001).await?;
let token = StpUtil::login(10001_i64).await?;
Source

pub async fn login_with_type( login_id: impl LoginId, _login_type: impl Into<String>, ) -> Result<TokenValue, SaTokenError>

Source

pub async fn login_with_extra( login_id: impl LoginId, extra_data: Value, ) -> Result<TokenValue, SaTokenError>

登录并设置额外数据 | Login with extra data

§参数 | Arguments
  • login_id - 登录ID | Login ID
  • extra_data - 额外数据 | Extra data
Source

pub async fn login_with_manager( manager: &SaTokenManager, login_id: impl Into<String>, ) -> Result<TokenValue, SaTokenError>

会话登录(带 manager 参数的版本,向后兼容)

Source

pub async fn logout(token: &TokenValue) -> Result<(), SaTokenError>

会话登出

Source

pub async fn logout_with_manager( manager: &SaTokenManager, token: &TokenValue, ) -> Result<(), SaTokenError>

Source

pub async fn kick_out(login_id: impl LoginId) -> Result<(), SaTokenError>

踢人下线(根据登录ID)

Source

pub async fn kick_out_with_manager( manager: &SaTokenManager, login_id: &str, ) -> Result<(), SaTokenError>

Source

pub async fn logout_by_login_id( login_id: impl LoginId, ) -> Result<(), SaTokenError>

强制登出(根据登录ID)

Source

pub async fn logout_by_token(token: &TokenValue) -> Result<(), SaTokenError>

根据 token 登出(别名方法,更直观)

Source

pub fn get_token_value() -> Result<TokenValue, SaTokenError>

获取当前请求的 token(无参数,从上下文获取)

§示例
// 在请求处理函数中
let token = StpUtil::get_token_value()?;
Source

pub async fn logout_current() -> Result<(), SaTokenError>

当前会话登出(无参数,从上下文获取 token)

§示例
// 在请求处理函数中
StpUtil::logout_current().await?;
Source

pub fn is_login_current() -> bool

检查当前会话是否登录(无参数,返回 bool)

§示例
// 在请求处理函数中
if StpUtil::is_login_current() {
    println!("当前用户已登录");
}
Source

pub fn check_login_current() -> Result<(), SaTokenError>

检查当前会话登录状态,未登录则抛出异常(无参数)

§示例
// 在请求处理函数中
StpUtil::check_login_current()?;
Source

pub async fn get_login_id_as_string() -> Result<String, SaTokenError>

获取当前会话的 login_id(String 类型,无参数)

§示例
// 在请求处理函数中
let login_id = StpUtil::get_login_id_as_string().await?;
Source

pub async fn get_login_id_as_long() -> Result<i64, SaTokenError>

获取当前会话的 login_id(i64 类型,无参数)

§示例
// 在请求处理函数中
let user_id = StpUtil::get_login_id_as_long().await?;
Source

pub fn get_token_info_current() -> Result<Arc<TokenInfo>, SaTokenError>

获取当前会话的 token 信息(无参数)

§示例
// 在请求处理函数中
let token_info = StpUtil::get_token_info_current()?;
println!("Token 创建时间: {:?}", token_info.create_time);
Source

pub async fn is_login(token: &TokenValue) -> bool

检查当前 token 是否已登录

Source

pub async fn is_login_by_login_id(login_id: impl LoginId) -> bool

根据登录 ID 检查是否已登录

§示例
let is_logged_in = StpUtil::is_login_by_login_id("user_123").await;
let is_logged_in = StpUtil::is_login_by_login_id(10001).await;
Source

pub async fn is_login_with_manager( manager: &SaTokenManager, token: &TokenValue, ) -> bool

Source

pub async fn check_login(token: &TokenValue) -> Result<(), SaTokenError>

检查当前 token 是否已登录,如果未登录则抛出异常

Source

pub async fn get_token_info( token: &TokenValue, ) -> Result<TokenInfo, SaTokenError>

获取 token 信息

Source

pub async fn get_login_id(token: &TokenValue) -> Result<String, SaTokenError>

获取当前 token 的登录ID

Source

pub async fn get_login_id_or_default( token: &TokenValue, default: impl Into<String>, ) -> String

获取当前 token 的登录ID,如果未登录则返回默认值

Source

pub async fn get_token_by_login_id( login_id: impl LoginId, ) -> Result<TokenValue, SaTokenError>

根据登录 ID 获取当前用户的 token

§示例
let token = StpUtil::get_token_by_login_id("user_123").await?;
let token = StpUtil::get_token_by_login_id(10001).await?;
Source

pub async fn get_all_tokens_by_login_id( login_id: impl LoginId, ) -> Result<Vec<TokenValue>, SaTokenError>

根据登录 ID 获取所有在线的 token 列表(支持多设备登录)

§示例
let tokens = StpUtil::get_all_tokens_by_login_id("user_123").await?;
Source

pub async fn get_session( login_id: impl LoginId, ) -> Result<SaSession, SaTokenError>

获取当前登录账号的 Session

Source

pub async fn save_session(session: &SaSession) -> Result<(), SaTokenError>

保存 Session

Source

pub async fn delete_session(login_id: impl LoginId) -> Result<(), SaTokenError>

删除 Session

Source

pub async fn set_session_value<T>( login_id: impl LoginId, key: &str, value: T, ) -> Result<(), SaTokenError>
where T: Serialize,

在 Session 中设置值

Source

pub async fn get_session_value<T>( login_id: impl LoginId, key: &str, ) -> Result<Option<T>, SaTokenError>

从 Session 中获取值

Source

pub fn create_token(token_value: impl Into<String>) -> TokenValue

创建一个新的 token(但不登录)

Source

pub fn is_valid_token_format(token: &str) -> bool

检查 token 格式是否有效(仅检查格式,不检查是否存在于存储中)

Source§

impl StpUtil

Source

pub async fn set_permissions( login_id: impl LoginId, permissions: Vec<String>, ) -> Result<(), SaTokenError>

为用户添加权限

Source

pub async fn add_permission( login_id: impl LoginId, permission: impl Into<String>, ) -> Result<(), SaTokenError>

为用户添加单个权限

Source

pub async fn remove_permission( login_id: impl LoginId, permission: &str, ) -> Result<(), SaTokenError>

移除用户的某个权限

Source

pub async fn clear_permissions( login_id: impl LoginId, ) -> Result<(), SaTokenError>

清除用户的所有权限

Source

pub async fn get_permissions(login_id: impl LoginId) -> Vec<String>

获取用户的所有权限

Source

pub async fn has_permission(login_id: impl LoginId, permission: &str) -> bool

检查用户是否拥有指定权限

Source

pub async fn has_all_permissions( login_id: impl LoginId, permissions: &[&str], ) -> bool

检查用户是否拥有所有指定权限(AND 逻辑)

Source

pub async fn has_permissions_and( login_id: impl LoginId, permissions: &[&str], ) -> bool

检查用户是否拥有所有指定权限(别名,AND 逻辑)

Source

pub async fn has_any_permission( login_id: impl LoginId, permissions: &[&str], ) -> bool

检查用户是否拥有任一指定权限(OR 逻辑)

Source

pub async fn has_permissions_or( login_id: impl LoginId, permissions: &[&str], ) -> bool

检查用户是否拥有任一指定权限(别名,OR 逻辑)

Source

pub async fn check_permission( login_id: impl LoginId, permission: &str, ) -> Result<(), SaTokenError>

检查权限,如果没有则抛出异常

Source§

impl StpUtil

Source

pub async fn set_roles( login_id: impl LoginId, roles: Vec<String>, ) -> Result<(), SaTokenError>

为用户设置角色

Source

pub async fn add_role( login_id: impl LoginId, role: impl Into<String>, ) -> Result<(), SaTokenError>

为用户添加单个角色

Source

pub async fn remove_role( login_id: impl LoginId, role: &str, ) -> Result<(), SaTokenError>

移除用户的某个角色

Source

pub async fn clear_roles(login_id: impl LoginId) -> Result<(), SaTokenError>

清除用户的所有角色

Source

pub async fn get_roles(login_id: impl LoginId) -> Vec<String>

获取用户的所有角色

Source

pub async fn has_role(login_id: impl LoginId, role: &str) -> bool

检查用户是否拥有指定角色

Source

pub async fn has_all_roles(login_id: impl LoginId, roles: &[&str]) -> bool

检查用户是否拥有所有指定角色(AND 逻辑)

Source

pub async fn has_roles_and(login_id: impl LoginId, roles: &[&str]) -> bool

检查用户是否拥有所有指定角色(别名,AND 逻辑)

Source

pub async fn has_any_role(login_id: impl LoginId, roles: &[&str]) -> bool

检查用户是否拥有任一指定角色(OR 逻辑)

Source

pub async fn has_roles_or(login_id: impl LoginId, roles: &[&str]) -> bool

检查用户是否拥有任一指定角色(别名,OR 逻辑)

Source

pub async fn check_role( login_id: impl LoginId, role: &str, ) -> Result<(), SaTokenError>

检查角色,如果没有则抛出异常

Source§

impl StpUtil

Source

pub async fn kick_out_batch<T>( login_ids: &[T], ) -> Result<Vec<Result<(), SaTokenError>>, SaTokenError>
where T: LoginId,

批量踢人下线

Source

pub async fn get_token_timeout( token: &TokenValue, ) -> Result<Option<i64>, SaTokenError>

获取 token 剩余有效时间(秒)

Source

pub async fn renew_timeout( token: &TokenValue, timeout_seconds: i64, ) -> Result<(), SaTokenError>

续期 token(重置过期时间)

Source

pub async fn set_extra_data( token: &TokenValue, extra_data: Value, ) -> Result<(), SaTokenError>

设置 Token 的额外数据 | Set extra data for token

§参数 | Arguments
  • token - Token值 | Token value
  • extra_data - 额外数据 | Extra data
Source

pub async fn get_extra_data( token: &TokenValue, ) -> Result<Option<Value>, SaTokenError>

获取 Token 的额外数据 | Get extra data from token

§参数 | Arguments
  • token - Token值 | Token value
Source

pub fn builder(login_id: impl LoginId) -> TokenBuilder

创建 Token 构建器,用于链式调用 | Create token builder for chain calls

§示例 | Example
use serde_json::json;
 
// 链式调用示例
let token = StpUtil::builder("user_123")
    .extra_data(json!({"ip": "192.168.1.1"}))
    .device("pc")
    .login_type("admin")
    .login()
    .await?;

Auto Trait Implementations§

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoCollection<T> for T

Source§

fn into_collection<A>(self) -> SmallVec<A>
where A: Array<Item = T>,

Converts self into a collection.
Source§

fn mapped<U, F, A>(self, f: F) -> SmallVec<A>
where F: FnMut(T) -> U, A: Array<Item = U>,

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Paint for T
where T: ?Sized,

Source§

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 primary(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Primary].

§Example
println!("{}", value.primary());
Source§

fn fixed(&self, color: u8) -> Painted<&T>

Returns self with the fg() set to [Color :: Fixed].

§Example
println!("{}", value.fixed(color));
Source§

fn rgb(&self, r: u8, g: u8, b: u8) -> Painted<&T>

Returns self with the fg() set to [Color :: Rgb].

§Example
println!("{}", value.rgb(r, g, b));
Source§

fn black(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Black].

§Example
println!("{}", value.black());
Source§

fn red(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Red].

§Example
println!("{}", value.red());
Source§

fn green(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Green].

§Example
println!("{}", value.green());
Source§

fn yellow(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Yellow].

§Example
println!("{}", value.yellow());
Source§

fn blue(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Blue].

§Example
println!("{}", value.blue());
Source§

fn magenta(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Magenta].

§Example
println!("{}", value.magenta());
Source§

fn cyan(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Cyan].

§Example
println!("{}", value.cyan());
Source§

fn white(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: White].

§Example
println!("{}", value.white());
Source§

fn bright_black(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightBlack].

§Example
println!("{}", value.bright_black());
Source§

fn bright_red(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightRed].

§Example
println!("{}", value.bright_red());
Source§

fn bright_green(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightGreen].

§Example
println!("{}", value.bright_green());
Source§

fn bright_yellow(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightYellow].

§Example
println!("{}", value.bright_yellow());
Source§

fn bright_blue(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightBlue].

§Example
println!("{}", value.bright_blue());
Source§

fn bright_magenta(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightMagenta].

§Example
println!("{}", value.bright_magenta());
Source§

fn bright_cyan(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightCyan].

§Example
println!("{}", value.bright_cyan());
Source§

fn bright_white(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightWhite].

§Example
println!("{}", value.bright_white());
Source§

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>

Returns self with the bg() set to [Color :: Primary].

§Example
println!("{}", value.on_primary());
Source§

fn on_fixed(&self, color: u8) -> Painted<&T>

Returns self with the bg() set to [Color :: Fixed].

§Example
println!("{}", value.on_fixed(color));
Source§

fn on_rgb(&self, r: u8, g: u8, b: u8) -> Painted<&T>

Returns self with the bg() set to [Color :: Rgb].

§Example
println!("{}", value.on_rgb(r, g, b));
Source§

fn on_black(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Black].

§Example
println!("{}", value.on_black());
Source§

fn on_red(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Red].

§Example
println!("{}", value.on_red());
Source§

fn on_green(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Green].

§Example
println!("{}", value.on_green());
Source§

fn on_yellow(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Yellow].

§Example
println!("{}", value.on_yellow());
Source§

fn on_blue(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Blue].

§Example
println!("{}", value.on_blue());
Source§

fn on_magenta(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Magenta].

§Example
println!("{}", value.on_magenta());
Source§

fn on_cyan(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Cyan].

§Example
println!("{}", value.on_cyan());
Source§

fn on_white(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: White].

§Example
println!("{}", value.on_white());
Source§

fn on_bright_black(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightBlack].

§Example
println!("{}", value.on_bright_black());
Source§

fn on_bright_red(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightRed].

§Example
println!("{}", value.on_bright_red());
Source§

fn on_bright_green(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightGreen].

§Example
println!("{}", value.on_bright_green());
Source§

fn on_bright_yellow(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightYellow].

§Example
println!("{}", value.on_bright_yellow());
Source§

fn on_bright_blue(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightBlue].

§Example
println!("{}", value.on_bright_blue());
Source§

fn on_bright_magenta(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightMagenta].

§Example
println!("{}", value.on_bright_magenta());
Source§

fn on_bright_cyan(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightCyan].

§Example
println!("{}", value.on_bright_cyan());
Source§

fn on_bright_white(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightWhite].

§Example
println!("{}", value.on_bright_white());
Source§

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 bold(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Bold].

§Example
println!("{}", value.bold());
Source§

fn dim(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Dim].

§Example
println!("{}", value.dim());
Source§

fn italic(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Italic].

§Example
println!("{}", value.italic());
Source§

fn underline(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Underline].

§Example
println!("{}", value.underline());

Returns self with the attr() set to [Attribute :: Blink].

§Example
println!("{}", value.blink());

Returns self with the attr() set to [Attribute :: RapidBlink].

§Example
println!("{}", value.rapid_blink());
Source§

fn invert(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Invert].

§Example
println!("{}", value.invert());
Source§

fn conceal(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Conceal].

§Example
println!("{}", value.conceal());
Source§

fn strike(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Strike].

§Example
println!("{}", value.strike());
Source§

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 mask(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Mask].

§Example
println!("{}", value.mask());
Source§

fn wrap(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Wrap].

§Example
println!("{}", value.wrap());
Source§

fn linger(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Linger].

§Example
println!("{}", value.linger());
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.

Returns self with the quirk() set to [Quirk :: Clear].

§Example
println!("{}", value.clear());
Source§

fn resetting(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Resetting].

§Example
println!("{}", value.resetting());
Source§

fn bright(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Bright].

§Example
println!("{}", value.bright());
Source§

fn on_bright(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: OnBright].

§Example
println!("{}", value.on_bright());
Source§

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§

fn new(self) -> Painted<Self>
where Self: Sized,

Create a new Painted with a default Style. Read more
Source§

fn paint<S>(&self, style: S) -> Painted<&Self>
where S: Into<Style>,

Apply a style wholesale to self. Any previous style is replaced. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more