App

Struct App 

Source
pub struct App {
Show 31 fields pub active_tab: Tab, pub users: Vec<User>, pub messages: HashMap<String, Vec<Message>>, pub current_peer: Option<String>, pub input_buffer: String, pub input_cursor: usize, pub selected_user: usize, pub is_mock_mode: bool, pub screen: AppScreen, pub passphrase: Option<Secret>, pub passphrase_input: String, pub splash_error: Option<String>, pub should_exit: bool, pub connection_status: ConnectionStatus, pub erlang_node_name: Option<String>, pub engine_status: Option<EngineStatus>, pub detailed_users: Option<Vec<DetailedUser>>, pub conversations: HashMap<String, ConversationView>, pub should_load_history: bool, pub status_message: Option<String>, pub admin_form: AdminForm, pub admin_mode: AdminMode, pub admin_selected_user: usize, pub certificates: Option<Vec<Certificate>>, pub certificates_for_user: Option<String>, pub admin_scroll_offset: u16, pub status_scroll_offset: u16, pub help_scroll_offset: u16, pub system_message_queue: VecDeque<SystemMessage>, pub current_system_message: Option<SystemMessage>, pub server_connection_up: bool,
}
Expand description

Main application state.

Contains all the data needed to render the UI and manage the application. This includes user lists, messages, input state, connection status, and more.

§Examples

use cryptic_tui::app::App;

// Create app with mock data for testing
let app = App::with_mock_data();

// Create empty app
let app = App::new();

Fields§

§active_tab: Tab

Currently active tab

§users: Vec<User>

List of all users

§messages: HashMap<String, Vec<Message>>

Messages grouped by peer username

§current_peer: Option<String>

Currently selected peer for chat

§input_buffer: String

Input buffer for message composition

§input_cursor: usize

Cursor position in input buffer (byte index, not char index)

§selected_user: usize

Currently selected user index in the user list

§is_mock_mode: bool

Whether running with mock data or real Erlang connection

§screen: AppScreen

Current screen (Splash or Main)

§passphrase: Option<Secret>

Encrypted passphrase (zeroized on drop)

§passphrase_input: String

Passphrase input buffer (cleared after validation)

§splash_error: Option<String>

Error message to display on splash screen

§should_exit: bool

Flag to trigger application exit

§connection_status: ConnectionStatus

Current Erlang connection status

§erlang_node_name: Option<String>

Name of the Erlang node to connect to

§engine_status: Option<EngineStatus>

Cryptographic engine status

§detailed_users: Option<Vec<DetailedUser>>

Detailed user list from admin API

§conversations: HashMap<String, ConversationView>

Active conversation views (keyed by peer username)

§should_load_history: bool

Flag to trigger history loading

§status_message: Option<String>

Status message to display to user (e.g., errors, notifications)

§admin_form: AdminForm

Pending admin form inputs

§admin_mode: AdminMode

Current admin view mode

§admin_selected_user: usize

Selected user index in admin user list

§certificates: Option<Vec<Certificate>>

Certificates for currently viewed user

§certificates_for_user: Option<String>

User whose certificates are being viewed

§admin_scroll_offset: u16

Admin view scroll offset (for scrolling content)

§status_scroll_offset: u16

Status view scroll offset (for scrolling content)

§help_scroll_offset: u16

Help view scroll offset (for scrolling content)

§system_message_queue: VecDeque<SystemMessage>

Queue of system messages to display

§current_system_message: Option<SystemMessage>

Currently displayed system message (if any)

§server_connection_up: bool

Server connection state (tracked via sys_code from system_message events)

Implementations§

Source§

impl App

Source

pub fn new() -> Self

Create a new empty App without mock data.

Used when connecting to a real Erlang node - users will be populated from the server’s user list.

Source

pub fn update_online_users(&mut self, online_users: Vec<String>)

Update the users list with online status from the server.

§Arguments
  • online_users - List of usernames currently online
Source

pub fn get_current_username(&self) -> Option<&str>

Get the current username from the Erlang node name.

Extracts the username portion before ‘@’ in node names like “alice@localhost”. Returns None if no node name is set.

Source

pub fn with_mock_data() -> Self

Create app with mock data for Phase 0 development.

Populates the app with sample users and messages for UI testing without requiring an Erlang connection.

Source

pub fn next_tab(&mut self)

Switch to next tab

Source

pub fn previous_tab(&mut self)

Switch to previous tab

Source

pub fn next_user(&mut self)

Select next user in the list

Source

pub fn previous_user(&mut self)

Select previous user in the list

Source

pub fn open_selected_chat(&mut self)

Open chat with selected user

Source

pub fn send_message(&mut self)

Send message from input buffer

Source

pub fn input_char(&mut self, c: char)

Add character to input buffer at cursor position

Source

pub fn input_backspace(&mut self)

Remove character before cursor (backspace)

Source

pub fn clear_input(&mut self)

Clear input buffer

Source

pub fn input_move_home(&mut self)

Move cursor to beginning of line (Ctrl-A)

Source

pub fn input_move_end(&mut self)

Move cursor to end of line (Ctrl-E)

Source

pub fn input_move_left(&mut self)

Move cursor left one character (Ctrl-B)

Source

pub fn input_move_right(&mut self)

Move cursor right one character (Ctrl-F)

Source

pub fn input_delete(&mut self)

Delete character at cursor (Delete key / Ctrl-D)

Source

fn char_index_to_byte_index(&self, char_index: usize) -> usize

Convert character index to byte index (for UTF-8 safety)

Source

pub fn receive_message(&mut self, from: &str, content: &str)

Simulate receiving a message (mock event bus)

Source

pub fn update_engine_status(&mut self, status: EngineStatus)

Update engine status with new data

Source

pub fn update_detailed_users(&mut self, users: Vec<DetailedUser>)

Update detailed user list from admin API

Source

pub fn set_status_message(&mut self, message: String)

Set a status message to display to the user.

§Arguments
  • message - The status message to display
Source

pub fn clear_status_message(&mut self)

Clear the current status message.

Source

pub fn admin_focus_next(&mut self)

Switch active admin form field.

Source

pub fn admin_focus_previous(&mut self)

Switch active admin form field in reverse order.

Source

pub fn admin_input_char(&mut self, ch: char)

Insert character into active admin field.

Source

pub fn admin_backspace(&mut self)

Handle backspace in active admin field.

Source

pub fn admin_clear_inputs(&mut self)

Clear both admin input fields.

Source

pub fn admin_form_complete(&self) -> bool

Determine if admin form is ready to submit.

Source

pub fn admin_next_user(&mut self)

Move to next user in admin user list.

Source

pub fn admin_previous_user(&mut self)

Move to previous user in admin user list.

Source

pub fn admin_get_selected_user(&self) -> Option<&DetailedUser>

Get currently selected user in admin list.

Source

pub fn admin_scroll_up(&mut self)

Scroll admin view up

Source

pub fn admin_scroll_down(&mut self)

Scroll admin view down

Source

pub fn admin_reset_scroll(&mut self)

Reset admin scroll to top

Source

pub fn status_scroll_up(&mut self)

Scroll status view up

Source

pub fn status_scroll_down(&mut self)

Scroll status view down

Source

pub fn status_reset_scroll(&mut self)

Reset status scroll to top

Source

pub fn help_scroll_up(&mut self)

Scroll help view up

Source

pub fn help_scroll_down(&mut self)

Scroll help view down

Source

pub fn help_reset_scroll(&mut self)

Reset help scroll to top

Source

pub fn get_conversation_mut(&mut self, peer: &str) -> &mut ConversationView

Get or create conversation view for a peer.

If a conversation doesn’t exist, creates a new one.

Source

pub fn get_conversation(&self, peer: &str) -> Option<&ConversationView>

Get conversation view (read-only).

Returns None if conversation doesn’t exist yet.

Source

pub fn add_system_message(&mut self, text: String, sys_code: Option<String>)

Add a system message to the queue.

If no message is currently being displayed, immediately shows the new message. Otherwise, adds it to the queue.

§Arguments
  • text - The message text to display
  • sys_code - Optional system code (Erlang atom) such as:
    • "server_connection_up" - Server is available
    • "server_connection_down" - Server is unavailable

When sys_code is “server_connection_down”, all users are marked as offline.

Source

pub fn update_system_message(&mut self)

Update the system message display, advancing to the next message if the minimum display time has elapsed.

Should be called periodically (e.g., from the event loop).

Source

pub fn get_current_system_message(&self) -> Option<&str>

Get the current system message text for display.

Source

pub fn clear_system_messages(&mut self)

Clear all system messages (current and queued).

Auto Trait Implementations§

§

impl Freeze for App

§

impl RefUnwindSafe for App

§

impl Send for App

§

impl Sync for App

§

impl Unpin 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<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> TryAsRef<T> for T

§

fn try_as_ref(&self) -> Option<&T>

§

impl<T> TryAsRef<T> for T

§

fn try_as_ref(&self) -> Option<&T>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

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