pub struct Builder<S, I, O> where
    I: AsyncRead + Unpin,
    O: Send + AsyncWrite + Unpin,
    S: Clone + Send
{ /* private fields */ }
Expand description

Builder for a new plugin.

Implementations

Subscribe to notifications for the given topic. The handler is an async function that takes a Plugin<S> and the notification as a serde_json::Value as inputs. Since notifications do not expect a result the handler should only report errors while processing. Any error reported while processing the notification will be logged in the cln logs.

use cln_plugin::{options, Builder, Error, Plugin};

async fn connect_handler(_p: Plugin<()>, v: serde_json::Value) -> Result<(), Error> {
    println!("Got a connect notification: {}", v);
    Ok(())
}

let b = Builder::new((), tokio::io::stdin(), tokio::io::stdout())
    .subscribe("connect", connect_handler);

Add a subscription to a given hookname

Register a custom RPC method for the RPC passthrough from the main daemon

Communicate with lightningd to tell it about our options, RPC methods and subscribe to hooks, and then process the initialization, configuring the plugin.

Returns None if we were invoked with --help and thus should exit after this handshake

Build and start the plugin loop. This performs the handshake and spawns a new task that accepts incoming messages from Core Lightning and dispatches them to the handlers. It only returns after completing the handshake to ensure that the configuration and initialization was successfull.

If lightningd was called with --help we won’t get a Plugin instance and return None instead. This signals that we should exit, and not continue running. start() returns in order to allow user code to perform cleanup if necessary.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.