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() -> Result<Self, HexchatError>

Gets the user’s current Context wrapped in a ThreadSafeContext object.

source

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

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
  • Ok(ThreadSafeContext) on success, and HexchatError on failure.
source

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

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<(), HexchatError>

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

source

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

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<(), HexchatError>

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

source

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

Gets a ThreadSafeListIterator from the context. If the list doesn’t exist, or a problem occurs, an error will be returned.

source

pub fn network(&self) -> Result<String, HexchatError>

Returns the network name associated with the context.

source

pub fn channel(&self) -> Result<String, HexchatError>

Returns the channel name associated with the context.

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 From<ThreadSafeFieldValue> for ThreadSafeContext

source§

fn from(v: ThreadSafeFieldValue) -> Self

Converts to this type from the input type.
source§

impl Send for ThreadSafeContext

source§

impl Sync for ThreadSafeContext

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere 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 Twhere 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 Twhere 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 Twhere 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.