[][src]Struct weechat::buffer::BufferBuilderAsync

pub struct BufferBuilderAsync { /* fields omitted */ }
This is supported on async only.

Builder for the creation of a buffer.

Implementations

impl BufferBuilderAsync[src]

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

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

Arguments

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

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

Panics

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

Example

fn input_cb(buffer: BufferHandle, input: String) -> LocalBoxFuture<'static, ()> {
    async move {
        let buffer = buffer.upgrade().unwrap();
        buffer.print(&input);
    }.boxed_local()
}

let buffer_handle = BufferBuilderAsync::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");

pub fn input_callback(self, callback: impl BufferInputCallbackAsync) -> Self[src]

Set the buffer input callback.

Arguments

  • callback - An async function that will be called once a user inputs data into the buffer input line.

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

Set the close callback.

Arguments

  • callback - The callback that should be called before a buffer is closed.

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

Build the configured buffer.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.