Skip to main content

RatatuiView

Struct RatatuiView 

Source
pub struct RatatuiView<F> { /* private fields */ }
Expand description

A Tuika view backed by a ratatui rendering closure.

The closure form is intentional: many ratatui widgets borrow their data. Captured owned data can be borrowed while constructing the widget inside the closure, without requiring a self-referential wrapper.

Implementations§

Source§

impl<F> RatatuiView<F>
where F: Fn(Rect, &mut Buffer),

Source

pub fn fill(render: F) -> Self

Create a view that requests all space offered by its parent.

use ratatui::widgets::{Block, Widget};
use tuika::interop::RatatuiView;

let view = RatatuiView::fill(|area, buffer| {
    Block::bordered().title(" ratatui ").render(area, buffer);
});
Source

pub fn sized(size: Size, render: F) -> Self

Create a view with a fixed intrinsic size for Dimension::Auto layout.

Trait Implementations§

Source§

impl<F> View for RatatuiView<F>
where F: Fn(Rect, &mut Buffer),

Source§

fn measure(&self, available: Size) -> Size

Report the intrinsic content size wanted given available.
Source§

fn render(&self, area: Rect, surface: &mut Surface<'_>, _ctx: &RenderCtx<'_>)

Paint the view into the assigned area through surface.

Auto Trait Implementations§

§

impl<F> Freeze for RatatuiView<F>
where F: Freeze,

§

impl<F> RefUnwindSafe for RatatuiView<F>
where F: RefUnwindSafe,

§

impl<F> Send for RatatuiView<F>
where F: Send,

§

impl<F> Sync for RatatuiView<F>
where F: Sync,

§

impl<F> Unpin for RatatuiView<F>
where F: Unpin,

§

impl<F> UnsafeUnpin for RatatuiView<F>
where F: UnsafeUnpin,

§

impl<F> UnwindSafe for RatatuiView<F>
where F: UnwindSafe,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. 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.