pub struct MainThreadToken(/* private fields */);Expand description
A witness of execution that exists solely on a designated “Main Thread”.
In FFI contexts, many libraries (especially legacy C++ or UI frameworks) are not thread-safe and must only be initialized, called, or dropped from the same thread that originally created them.
MainThreadToken is a zero-sized proof carrier. Possessing it proves
(at a type-system level) that you are currently executing on the designated
main thread.
Implementations§
Source§impl MainThreadToken
impl MainThreadToken
Sourcepub unsafe fn new_unchecked() -> Self
pub unsafe fn new_unchecked() -> Self
Create a new MainThreadToken.
§Safety
This must only be called from the designated main application thread. In VT Code, this is typically the thread that initializes the TUI or the first boot thread.
Trait Implementations§
Source§impl Clone for MainThreadToken
impl Clone for MainThreadToken
Source§fn clone(&self) -> MainThreadToken
fn clone(&self) -> MainThreadToken
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MainThreadToken
impl Debug for MainThreadToken
Source§impl PartialEq for MainThreadToken
impl PartialEq for MainThreadToken
impl Copy for MainThreadToken
impl Eq for MainThreadToken
impl StructuralPartialEq for MainThreadToken
Auto Trait Implementations§
impl Freeze for MainThreadToken
impl RefUnwindSafe for MainThreadToken
impl !Send for MainThreadToken
impl !Sync for MainThreadToken
impl Unpin for MainThreadToken
impl UnsafeUnpin for MainThreadToken
impl UnwindSafe for MainThreadToken
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<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
Compare self to
key and return true if they are equal.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