Skip to main content

Json

Struct Json 

Source
pub struct Json {
    pub renderer: Option<SharedRenderer<Index>>,
    pub evaluator: Evaluator<Self>,
    pub title: State,
    pub json: State,
}
Available on crate feature json only.
Expand description

Represents a JSON preset for rendering JSON data and titles with customizable styles.

Fields§

§renderer: Option<SharedRenderer<Index>>

Shared renderer for the prompt, allowing for rendering of UI components.

§evaluator: Evaluator<Self>

Function to evaluate the input events and update the state of the prompt.

§title: State

State for the title text.

§json: State

State for the JSON data, including formatting and rendering options.

Implementations§

Source§

impl Json

Source

pub fn new(stream: JsonStream) -> Self

Creates a new JSON preset with the provided JSON stream.

Source

pub fn title<T: AsRef<str>>(self, text: T) -> Self

Sets the title text for the JSON preset.

Source

pub fn title_style(self, style: ContentStyle) -> Self

Sets the style for the title text.

Source

pub fn json_lines(self, lines: usize) -> Self

Sets the number of lines to be used for rendering the JSON data.

Source

pub fn indent(self, indent: usize) -> Self

Sets the indentation level for rendering the JSON data.

Source

pub fn overflow_mode(self, mode: OverflowMode) -> Self

Sets the overflow mode for rendering JSON values that exceed the available width.

Source

pub fn active_item_attribute(self, attr: Attribute) -> Self

Sets the attribute for active (currently selected) items.

Source

pub fn inactive_item_attribute(self, attr: Attribute) -> Self

Sets the attribute for inactive (not currently selected) items.

Source

pub fn evaluator(self, evaluator: Evaluator<Self>) -> Self

Sets the evaluator function for handling events in the JSON preset.

Trait Implementations§

Source§

impl Prompt for Json

Source§

type Return = ()

The type of the result produced by the renderer.
Source§

fn initialize<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Initializes the handler, preparing it for use. This method is called before the prompt starts running. Read more
Source§

fn evaluate<'life0, 'life1, 'async_trait>( &'life0 mut self, event: &'life1 Event, ) -> Pin<Box<dyn Future<Output = Result<Signal>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Evaluates an event and determines the next action for the prompt. Read more
Source§

fn finalize(&mut self) -> Result<Self::Return>

Finalizes the prompt and produces a result. Read more
Source§

fn run<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<Self::Return>> + Send + 'async_trait>>
where Self: Send + 'async_trait, 'life0: 'async_trait,

Runs the prompt, handling events and producing a result. Read more

Auto Trait Implementations§

§

impl Freeze for Json

§

impl !RefUnwindSafe for Json

§

impl Send for Json

§

impl Sync for Json

§

impl Unpin for Json

§

impl UnsafeUnpin for Json

§

impl !UnwindSafe for Json

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

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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.