#![deny(missing_docs, clippy::pedantic)]
#![allow(
clippy::cast_sign_loss,
clippy::cast_possible_truncation,
clippy::cast_possible_wrap,
clippy::module_name_repetitions
)]
#![feature(
slice_patterns,
trait_alias,
type_alias_enum_variants,
never_type,
fnbox,
proc_macro_hygiene
)]
use std::ffi::{CStr, CString};
use std::os::raw::c_char;
#[doc(hidden)]
pub mod c;
mod get_info;
pub use crate::get_info::*;
mod lists;
pub use crate::lists::*;
mod hook;
pub use crate::hook::*;
mod other;
pub use crate::other::*;
mod msg;
pub use crate::msg::*;
mod prefs;
pub use crate::prefs::*;
mod chan;
pub use crate::chan::*;
mod subplugin;
pub use crate::subplugin::*;
mod mask;
pub use crate::mask::*;
#[macro_use]
mod safe_static;
pub use crate::safe_static::*;
pub mod server_event;
pub mod reply;
#[macro_use]
#[doc(hidden)]
pub mod call;
fn to_cstring(str: &str) -> CString {
CString::new(str).unwrap_or_else(|_| CString::new(str.replace('\0', "")).unwrap())
}
unsafe fn from_cstring(ptr: *const c_char) -> String {
CStr::from_ptr(ptr).to_string_lossy().into_owned()
}
unsafe fn from_cstring_opt(ptr: *const c_char) -> Option<String> {
if ptr.is_null() {
None
} else {
Some(from_cstring(ptr))
}
}
pub struct Context {
handle: *mut c::hexchat_plugin,
}
impl Context {
pub fn send_command(&self, command: &str) {
let command = to_cstring(command);
unsafe {
c!(hexchat_command, self.handle, command.as_ptr());
}
}
}
pub trait Plugin {
const NAME: &'static str;
const DESC: &'static str = "";
const VERSION: &'static str = "";
fn new(context: &Context) -> Self;
}