Struct hexchat_api::Context

source ·
pub struct Context { /* private fields */ }
Expand description

Any channel in Hexchat has an associated IRC network name and channel name. The network name and channel name are closely associated with the Hexchat concept of contexts. Hexchat contexts can also be thought of as the tabs, or windows, open in the UI that have the user joined to their various “chat rooms”. To access a specific chat window in Hexchat, its context can be acquired and used. This library’s Context objects represent the Hexchat contexts and can be used to interact with the specific channels/windows/tabs that he user has open. For instance if your plugin needs to output only to specific channels, rather than the default window (which is the one currently open) - it can acquire the appropriate context using Context::find("some-network", "some-channel"), and use the object returned to invoke a command, context.command("SAY hello!"), or print, context.print("Hello!"), or perform other operations.

Implementations§

source§

impl Context

source

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

This will create a new Context object holding an internal pointer to the requested network/channel, if it exists. The object will be returned as a Some<Context> if the context is found, or None if not.

source

pub fn get() -> Option<Self>

This will create a new Context that represents the currently active context (window/tab, channel/network) open on the user’s screen. An Context object is returned, or None if it couldn’t be obtained.

source

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

Sets the currently active context to the context the Context object points to internally.

source

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

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

source

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

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

source

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

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

source

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

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

source

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

Gets a ListIterator from the context held by the Context object.

source

pub fn network(&self) -> String

Returns the network name associated with the Context object.

source

pub fn channel(&self) -> String

Returns the channel name associated with the Context object.

Trait Implementations§

source§

impl Clone for Context

source§

fn clone(&self) -> Context

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 Context

source§

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

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

impl Display for Context

source§

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

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

impl From<FieldValue> for Context

source§

fn from(v: FieldValue) -> Self

Converts to this type from the input type.

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.