Struct BufferBuilder

Source
pub struct BufferBuilder { /* private fields */ }
Expand description

Builder for the creation of a buffer.

Implementations§

Source§

impl BufferBuilder

Source

pub fn new(name: &str) -> Self

Create a new buffer builder that will create a buffer with an sync input callback.

§Arguments
  • name - The name of the new buffer. Needs to be unique across a plugin, otherwise the buffer creation will fail.
§Panics

Panics if the method is not called from the main Weechat thread.

Returns a Buffer if one has been created, otherwise an empty Error.

§Example
fn input_cb(weechat: &Weechat, buffer: &Buffer, input: Cow<str>) -> Result<(), ()> {
    buffer.print(&input);
    Ok(())
}

let buffer_handle = BufferBuilder::new("test_buffer")
    .input_callback(input_cb)
    .close_callback(|weechat: &Weechat, buffer: &Buffer| {
        Ok(())
})
    .build()
    .expect("Can't create new buffer");

let buffer = buffer_handle
    .upgrade()
    .expect("Can't upgrade newly created buffer");

buffer.enable_nicklist();
buffer.print("Hello world");
Source

pub fn input_callback( self, callback: impl BufferInputCallback + 'static, ) -> Self

Set the buffer input callback.

§Arguments
  • callback - A function or a struct that implements the BufferCloseCallback trait.
Source

pub fn close_callback( self, callback: impl BufferCloseCallback + 'static, ) -> Self

Set the close callback.

§Arguments
  • callback - The callback that should be called before a buffer is
Source

pub fn build(self) -> Result<BufferHandle, ()>

Build the configured buffer.

Auto Trait Implementations§

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> 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, 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.