pub struct Ctx { /* private fields */ }Expand description
可克隆的取消上下文。handler 用 ctx.cancelled() 做周期检查,
长任务可在退出前排空。
Implementations§
Source§impl Ctx
impl Ctx
Sourcepub fn raw(&self) -> Arc<AtomicBool> ⓘ
pub fn raw(&self) -> Arc<AtomicBool> ⓘ
返回一个可以在线程/任务间共享的底层句柄(信号线程用)。
Sourcepub fn with_language(&self, lang: &str) -> Ctx
pub fn with_language(&self, lang: &str) -> Ctx
派生一个携带指定界面语言的上下文(spec §11.7 的逐请求语言载体)。
Source§impl Ctx
impl Ctx
Sourcepub async fn cancelled_async(&self)
pub async fn cancelled_async(&self)
在 tokio 任务里等待取消(HTTP/MCP 模式的优雅关停 select 用)。
Trait Implementations§
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
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