Struct hexchat_api::ThreadSafeHexchat
source · 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
impl ThreadSafeHexchat
sourcepub fn command(&self, command: &str) -> Result<(), HexchatError>
pub fn command(&self, command: &str) -> Result<(), HexchatError>
Invokes the Hexchat command specified by command
.
Arguments
command
- The Hexchat command to invoke.
sourcepub fn find_context(
&self,
network: &str,
channel: &str
) -> Result<ThreadSafeContext, HexchatError>
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..
sourcepub fn get_context(&self) -> Result<ThreadSafeContext, HexchatError>
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.
sourcepub fn get_info(&self, id: &str) -> Result<String, HexchatError>
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 underhexchat_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 requestedid
or another problem occurred.
sourcepub fn list_get(
&self,
list: &str
) -> Result<ThreadSafeListIterator, HexchatError>
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
impl Clone for ThreadSafeHexchat
source§fn clone(&self) -> ThreadSafeHexchat
fn clone(&self) -> ThreadSafeHexchat
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more