pub struct ThreadSafeContext { /* private fields */ }
Expand description

A thread-safe version of Context. Its methods automatically execute on the Hexchat main thread. The full set of methods of Context aren’t fully implemented for this struct because some can’t be trusted to produce predictable results from other threads. For instance .set() from a thread would only cause Hexchat to momentarily set its context, but Hexchat’s context could change again at any moment while the other thread is executing.

Implementations§

source§

impl ThreadSafeContext

source

pub fn get() -> Option<Self>

Gets the current Context wrapped in a ThreadSafeContext object. This method should be called from the Hexchat main thread for it to contain a predictable Context. Executing it from a thread can yield a wrapped Context for an unexpected channel.

source

pub fn find(network: &str, channel: &str) -> Option<Self>

Gets a ThreadSafeContext object associated with the given channel.

Arguments
  • network - The network of the channel to get the context for.
  • channel - The channel to get the context of.
Returns
  • Some(ThreadSafeContext) on success, and None on failure.
source

pub fn print(&self, message: &str) -> Result<(), ContextError>

Prints the message to the ThreadSafeContext object’s Hexchat context. This is how messages can be printed to Hexchat windows apart from the currently active one.

source

pub fn aprint(&self, message: &str)

Prints without waiting for asynchronous completion. This will print faster than .print() because it just stacks up print requests in the timer queue and moves on without blocking. The downside is errors will not be checked. Error messages will, however, still be printed if any occur.

source

pub fn command(&self, command: &str) -> Result<(), ContextError>

Issues a command in the context held by the ThreadSafeContext object.

source

pub fn get_info(&self, info: &str) -> Result<Option<String>, ContextError>

Gets information from the channel/window that the ThreadSafeContext object holds an internal pointer to.

source

pub fn emit_print( &self, event_name: &str, var_args: &[&str] ) -> Result<(), ContextError>

Issues a print event to the context held by the ThreadSafeContext object.

source

pub fn list_get( &self, name: &str ) -> Result<Option<ThreadSafeListIterator>, ContextError>

Gets a ListIterator from the context held by the Context object. If the list doesn’t exist, the OK() result will contain None; otherwise it will hold the listIterator object for the requested list.

Trait Implementations§

source§

impl Clone for ThreadSafeContext

source§

fn clone(&self) -> ThreadSafeContext

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for ThreadSafeContext

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Display for ThreadSafeContext

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Drop for ThreadSafeContext

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl Send for ThreadSafeContext

source§

impl Sync for ThreadSafeContext

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

source§

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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

type Error = Infallible

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

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

Performs the conversion.
source§

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.
source§

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

Performs the conversion.