Skip to main content

App

Struct App 

Source
pub struct App {
Show 18 fields pub state: TextArea<'static>, pub questions: Vec<QuestionDraft>, pub selected: usize, pub focus: Focus, pub model: Option<String>, pub models: Vec<String>, pub calibration: Option<f64>, pub status: Status, pub answers: Option<Answers>, pub stale: bool, pub answers_scroll: u16, pub answers_max_scroll: Cell<u16>, pub editor: Option<Editor>, pub show_help: bool, pub url: String, pub healthy: Option<bool>, pub should_quit: bool, pub tick: u64, /* private fields */
}

Fields§

§state: TextArea<'static>§questions: Vec<QuestionDraft>§selected: usize

Ranges over 0..=questions.len(): one past the last question is the “add” row.

§focus: Focus§model: Option<String>§models: Vec<String>

Aliases offered by the service, for cycling with m.

§calibration: Option<f64>§status: Status§answers: Option<Answers>§stale: bool

Whether answers belongs to an older request than the form now describes.

§answers_scroll: u16

Lines of the answers pane scrolled past the top.

§answers_max_scroll: Cell<u16>

How far the answers pane can scroll, as the last draw found it. Only drawing knows how many lines the answers wrap to, so the renderer records it here and scrolling stops there, instead of running on into blank space that then takes as many presses to undo.

§editor: Option<Editor>§show_help: bool§url: String§healthy: Option<bool>§should_quit: bool§tick: u64

Advances once per tick; drives the spinner.

Implementations§

Source§

impl App

Source

pub fn new(session: Session, url: String) -> Self

Source

pub fn state_text(&self) -> String

Source

pub fn to_session(&self) -> Session

Source

pub fn on_add_row(&self) -> bool

Whether the cursor is on the “add question” row after the last question.

Source

pub fn select_next(&mut self)

Source

pub fn select_previous(&mut self)

Source

pub fn add_question(&mut self)

Open the editor on a new question, offering an id that does not collide with an existing one. The field itself starts empty; see Editor::adding.

Source

pub fn edit_selected(&mut self)

Edit the selected question, or start a new one when the cursor is on the add row.

Source

pub fn delete_selected(&mut self)

Source

pub fn commit_editor(&mut self)

Take the draft out of the editor and put it where it belongs.

Source

pub fn cancel_editor(&mut self)

Source

pub fn cycle_model(&mut self)

Step through the service’s aliases, then back to “the server’s default”.

Source

pub fn build<'a>(&self, client: &'a Client) -> SystemOne<'a>

Assemble the request this form describes. See Session::build.

Source

pub fn is_sending(&self) -> bool

Source

pub fn begin_send(&mut self) -> u64

Enter the sending state and return the generation the result must carry to be accepted.

Source

pub fn finish_send( &mut self, generation: u64, result: Result<Answers, Error>, ) -> bool

Take a request’s result. Returns whether it was accepted, i.e. whether it belonged to the request currently in flight.

Source

pub fn answer_order(&self) -> Vec<&str>

The ids of the answers on screen, in the order their questions were asked.

The response keys its answers by id, which sorts q10 before q2 and team before urgent. Anything the service answered that was not in the sent list — which a normal round trip never produces — follows in the response’s order rather than being hidden.

Source

pub fn scroll_answers(&mut self, lines: i32)

Scroll the answers pane by lines, down for positive, within what the last draw allows.

Source

pub fn question_for(&self, id: &str) -> Option<&str>

The question text an answer on screen was asked with.

Source

pub fn cancel_send(&mut self)

Source

pub fn failure(&self) -> Option<&Failure>

Source

pub fn is_blamed(&self, index: usize) -> bool

Whether the question at index is the one the service refused.

Source

pub fn mark_stale(&mut self)

The form has changed since the answers on screen were produced.

Auto Trait Implementations§

§

impl !Freeze for App

§

impl !RefUnwindSafe for App

§

impl !Sync for App

§

impl Send for App

§

impl Unpin for App

§

impl UnsafeUnpin for App

§

impl UnwindSafe for App

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.

§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. 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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more