pub struct ThreadSafeHexchat;
Expand description

A thread-safe wrapper for the Hexchat object. It implements a subset of the methods provided by the wrapped object. A lot of methods don’t make sense to expose; those that do should provide enough utility to code that needs to invoke Hexchat from other threads.

Implementations§

source§

impl ThreadSafeHexchat

source

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

Prints the string passed to it to the active Hexchat window.

Arguments
  • text - The text to print.
source

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

Invokes the Hexchat command specified by command.

Arguments
  • command - The Hexchat command to invoke.
source

pub fn find_context( &self, network: &str, channel: &str ) -> Result<ThreadSafeContext, HexchatError>

Returns a ThreadSafeContext object bound to the requested channel. The object provides methods like print() that will execute the Hexchat print command in that tab/window related to the context. The Context::find() can also be invoked to find a context.

Arguments
  • network - The network (e.g. “freenode”) of the context.
  • channel - The channel name for the context (e.g. “##rust”).
Returns
  • the thread-safe context was found, i.e. if the user is joined to the channel specified currently, the context or a HexchatError if the context wasn’t found, or another problem occurred..
source

pub fn get_context(&self) -> Result<ThreadSafeContext, HexchatError>

This should be invoked from the main thread. The context object returned can then be moved to a thread that uses it. Executing this from a separate thread may not grab the expected context internally.

Returns a ThreadSafeContext object for the current context currently visible in the app). This object can be used to invoke the Hexchat API within the context the object is bound to. Also, Context::get() will return a context object for the current context.

Returns
  • The ThreadSafeContext for the currently active context. This usually means the channel window the user has visible in the GUI.
source

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

Retrieves the info data with the given id. It returns None on failure and Some(String) on success. All information is returned as String data - even the “win_ptr”/“gtkwin_ptr” values, which can be parsed and cast to pointers.

Arguments
  • id - The name/identifier for the information needed. A list of the names for some of these can be found on the Hexchat Plugin Interface page under hexchat_get_info(). These include “channel”, “network”, “topic”, etc.
Returns
  • The string is returned for the info requested. HexchatError is returned if there is no info with the requested id or another problem occurred.
source

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

Creates an iterator for the requested Hexchat list. This is modeled after how Hexchat implements the listing feature: rather than load all the list items up front, an internal list pointer is advanced to the current item, and the fields of which are accessible through the iterator’s .get_field() function. See the Hexchat Plugin Interface web page for more information on the related lists.

Arguments
  • name - The name of the list to iterate over.
Returns
  • If the list exists, a ThreadSafeListIterator is returned otherwise, an error is returned.

Trait Implementations§

source§

impl Clone for ThreadSafeHexchat

source§

fn clone(&self) -> ThreadSafeHexchat

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 Copy for ThreadSafeHexchat

source§

impl Send for ThreadSafeHexchat

source§

impl Sync for ThreadSafeHexchat

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, 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.