Plugin

Struct Plugin 

Source
pub struct Plugin<T>
where T: 'static + Clone,
{ pub state: T, pub option: HashMap<String, RpcOption>, pub rpc_method: HashMap<String, Box<dyn RPCCommand<T>>>, pub rpc_info: HashSet<RPCMethodInfo>, pub rpc_hook: HashMap<String, Box<dyn RPCCommand<T>>>, pub hook_info: HashSet<RPCHookInfo>, pub rpc_notification: HashMap<String, Box<dyn RPCCommand<T>>>, pub dynamic: bool, pub configuration: Option<CLNConf>, /* private fields */ }

Fields§

§state: T§option: HashMap<String, RpcOption>

all the option contained inside the hash map.

§rpc_method: HashMap<String, Box<dyn RPCCommand<T>>>

all the options rpc method that the plugin need to support, included the builtin rpc method.

§rpc_info: HashSet<RPCMethodInfo>

keep the info of the method in a separate list FIXME: move the RPCMethodInfo as key of the rpc_method map.

§rpc_hook: HashMap<String, Box<dyn RPCCommand<T>>>

all the hook where the plugin is register during the configuration

§hook_info: HashSet<RPCHookInfo>

keep all the info about the hooks in a separate set. FIXME: put the RPCHookInfo as key of the hash map.

§rpc_notification: HashMap<String, Box<dyn RPCCommand<T>>>

all the notification that the plugin is register on

§dynamic: bool

mark a plugin as dynamic, in this way the plugin can be run from core lightning without stop the lightningd daemon

§configuration: Option<CLNConf>

core lightning configuration sent with the init call.

Implementations§

Source§

impl<'a, T: 'a + Clone> Plugin<T>

Source

pub fn new(state: T, dynamic: bool) -> Self

Source

pub fn on_init<C>(&'a mut self, callback: C) -> Self
where C: Fn(&mut Plugin<T>) -> Value + 'static,

Source

pub fn log(&self, level: LogLevel, msg: &str)

Source

pub fn add_opt( &mut self, name: &str, opt_type: &str, def_val: Option<String>, description: &str, deprecated: bool, ) -> &mut Self

register the plugin option.

Source

pub fn get_opt<R: for<'de> Deserialize<'de>>( &self, name: &str, ) -> Result<R, PluginError>

get an optionue that cln sent back to the plugin.

Source

pub fn add_rpc_method<F>( &'a mut self, name: &str, usage: &str, description: &str, callback: F, ) -> Self
where F: RPCCommand<T> + 'static,

Source

pub fn register_hook<F>( &'a mut self, hook_name: &str, before: Option<Vec<String>>, after: Option<Vec<String>>, callback: F, ) -> Self
where F: RPCCommand<T> + 'static,

Source

pub fn register_notification<F>(&mut self, name: &str, callback: F) -> Self
where F: 'static + RPCCommand<T> + Clone,

Source

pub fn start(self)

Trait Implementations§

Source§

impl<T> Clone for Plugin<T>
where T: 'static + Clone + Clone,

Source§

fn clone(&self) -> Plugin<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Plugin<T>
where T: Freeze,

§

impl<T> !RefUnwindSafe for Plugin<T>

§

impl<T> !Send for Plugin<T>

§

impl<T> !Sync for Plugin<T>

§

impl<T> Unpin for Plugin<T>
where T: Unpin,

§

impl<T> !UnwindSafe for Plugin<T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 T
where 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 T
where T: Clone,

Source§

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 T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.