[−][src]Struct weechat::buffer::BufferBuilderAsync
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]
self,
callback: impl BufferCloseCallback + 'static
) -> Self
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
impl !RefUnwindSafe for BufferBuilderAsync
impl !Send for BufferBuilderAsync
impl !Sync for BufferBuilderAsync
impl Unpin for BufferBuilderAsync
impl !UnwindSafe for BufferBuilderAsync
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,