Struct hexchat_api::ThreadSafeContext
source · 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
impl ThreadSafeContext
sourcepub fn get() -> Result<Self, HexchatError>
pub fn get() -> Result<Self, HexchatError>
Gets the user’s current Context
wrapped in a ThreadSafeContext
object.
sourcepub fn print(&self, message: &str) -> Result<(), HexchatError>
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.
sourcepub fn aprint(&self, message: &str)
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.
sourcepub fn command(&self, command: &str) -> Result<(), HexchatError>
pub fn command(&self, command: &str) -> Result<(), HexchatError>
Issues a command in the context held by the ThreadSafeContext
object.
sourcepub fn get_info(&self, info: &str) -> Result<String, HexchatError>
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.
sourcepub fn emit_print(
&self,
event_name: &str,
var_args: &[&str]
) -> Result<(), HexchatError>
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.
sourcepub fn list_get(
&self,
name: &str
) -> Result<ThreadSafeListIterator, HexchatError>
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.
sourcepub fn network(&self) -> Result<String, HexchatError>
pub fn network(&self) -> Result<String, HexchatError>
Returns the network name associated with the context.
sourcepub fn channel(&self) -> Result<String, HexchatError>
pub fn channel(&self) -> Result<String, HexchatError>
Returns the channel name associated with the context.
Trait Implementations§
source§impl Clone for ThreadSafeContext
impl Clone for ThreadSafeContext
source§fn clone(&self) -> ThreadSafeContext
fn clone(&self) -> ThreadSafeContext
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more