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: TabCurrently 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: StringInput buffer for message composition
input_cursor: usizeCursor position in input buffer (byte index, not char index)
selected_user: usizeCurrently selected user index in the user list
is_mock_mode: boolWhether running with mock data or real Erlang connection
screen: AppScreenCurrent screen (Splash or Main)
passphrase: Option<Secret>Encrypted passphrase (zeroized on drop)
passphrase_input: StringPassphrase input buffer (cleared after validation)
splash_error: Option<String>Error message to display on splash screen
should_exit: boolFlag to trigger application exit
connection_status: ConnectionStatusCurrent 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: boolFlag to trigger history loading
status_message: Option<String>Status message to display to user (e.g., errors, notifications)
admin_form: AdminFormPending admin form inputs
admin_mode: AdminModeCurrent admin view mode
admin_selected_user: usizeSelected 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: u16Admin view scroll offset (for scrolling content)
status_scroll_offset: u16Status view scroll offset (for scrolling content)
help_scroll_offset: u16Help 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: boolServer connection state (tracked via sys_code from system_message events)
Implementations§
Source§impl App
impl App
Sourcepub fn new() -> Self
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.
Sourcepub fn update_online_users(&mut self, online_users: Vec<String>)
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
Sourcepub fn get_current_username(&self) -> Option<&str>
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.
Sourcepub fn with_mock_data() -> Self
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.
Sourcepub fn previous_tab(&mut self)
pub fn previous_tab(&mut self)
Switch to previous tab
Sourcepub fn previous_user(&mut self)
pub fn previous_user(&mut self)
Select previous user in the list
Sourcepub fn open_selected_chat(&mut self)
pub fn open_selected_chat(&mut self)
Open chat with selected user
Sourcepub fn send_message(&mut self)
pub fn send_message(&mut self)
Send message from input buffer
Sourcepub fn input_char(&mut self, c: char)
pub fn input_char(&mut self, c: char)
Add character to input buffer at cursor position
Sourcepub fn input_backspace(&mut self)
pub fn input_backspace(&mut self)
Remove character before cursor (backspace)
Sourcepub fn clear_input(&mut self)
pub fn clear_input(&mut self)
Clear input buffer
Sourcepub fn input_move_home(&mut self)
pub fn input_move_home(&mut self)
Move cursor to beginning of line (Ctrl-A)
Sourcepub fn input_move_end(&mut self)
pub fn input_move_end(&mut self)
Move cursor to end of line (Ctrl-E)
Sourcepub fn input_move_left(&mut self)
pub fn input_move_left(&mut self)
Move cursor left one character (Ctrl-B)
Sourcepub fn input_move_right(&mut self)
pub fn input_move_right(&mut self)
Move cursor right one character (Ctrl-F)
Sourcepub fn input_delete(&mut self)
pub fn input_delete(&mut self)
Delete character at cursor (Delete key / Ctrl-D)
Sourcefn char_index_to_byte_index(&self, char_index: usize) -> usize
fn char_index_to_byte_index(&self, char_index: usize) -> usize
Convert character index to byte index (for UTF-8 safety)
Sourcepub fn receive_message(&mut self, from: &str, content: &str)
pub fn receive_message(&mut self, from: &str, content: &str)
Simulate receiving a message (mock event bus)
Sourcepub fn update_engine_status(&mut self, status: EngineStatus)
pub fn update_engine_status(&mut self, status: EngineStatus)
Update engine status with new data
Sourcepub fn update_detailed_users(&mut self, users: Vec<DetailedUser>)
pub fn update_detailed_users(&mut self, users: Vec<DetailedUser>)
Update detailed user list from admin API
Sourcepub fn set_status_message(&mut self, message: String)
pub fn set_status_message(&mut self, message: String)
Sourcepub fn clear_status_message(&mut self)
pub fn clear_status_message(&mut self)
Clear the current status message.
Sourcepub fn admin_focus_next(&mut self)
pub fn admin_focus_next(&mut self)
Switch active admin form field.
Sourcepub fn admin_focus_previous(&mut self)
pub fn admin_focus_previous(&mut self)
Switch active admin form field in reverse order.
Sourcepub fn admin_input_char(&mut self, ch: char)
pub fn admin_input_char(&mut self, ch: char)
Insert character into active admin field.
Sourcepub fn admin_backspace(&mut self)
pub fn admin_backspace(&mut self)
Handle backspace in active admin field.
Sourcepub fn admin_clear_inputs(&mut self)
pub fn admin_clear_inputs(&mut self)
Clear both admin input fields.
Sourcepub fn admin_form_complete(&self) -> bool
pub fn admin_form_complete(&self) -> bool
Determine if admin form is ready to submit.
Sourcepub fn admin_next_user(&mut self)
pub fn admin_next_user(&mut self)
Move to next user in admin user list.
Sourcepub fn admin_previous_user(&mut self)
pub fn admin_previous_user(&mut self)
Move to previous user in admin user list.
Sourcepub fn admin_get_selected_user(&self) -> Option<&DetailedUser>
pub fn admin_get_selected_user(&self) -> Option<&DetailedUser>
Get currently selected user in admin list.
Sourcepub fn admin_scroll_up(&mut self)
pub fn admin_scroll_up(&mut self)
Scroll admin view up
Sourcepub fn admin_scroll_down(&mut self)
pub fn admin_scroll_down(&mut self)
Scroll admin view down
Sourcepub fn admin_reset_scroll(&mut self)
pub fn admin_reset_scroll(&mut self)
Reset admin scroll to top
Sourcepub fn status_scroll_up(&mut self)
pub fn status_scroll_up(&mut self)
Scroll status view up
Sourcepub fn status_scroll_down(&mut self)
pub fn status_scroll_down(&mut self)
Scroll status view down
Sourcepub fn status_reset_scroll(&mut self)
pub fn status_reset_scroll(&mut self)
Reset status scroll to top
Sourcepub fn help_scroll_up(&mut self)
pub fn help_scroll_up(&mut self)
Scroll help view up
Sourcepub fn help_scroll_down(&mut self)
pub fn help_scroll_down(&mut self)
Scroll help view down
Sourcepub fn help_reset_scroll(&mut self)
pub fn help_reset_scroll(&mut self)
Reset help scroll to top
Sourcepub fn get_conversation_mut(&mut self, peer: &str) -> &mut ConversationView
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.
Sourcepub fn get_conversation(&self, peer: &str) -> Option<&ConversationView>
pub fn get_conversation(&self, peer: &str) -> Option<&ConversationView>
Get conversation view (read-only).
Returns None if conversation doesn’t exist yet.
Sourcepub fn add_system_message(&mut self, text: String, sys_code: Option<String>)
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 displaysys_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.
Sourcepub fn update_system_message(&mut self)
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).
Sourcepub fn get_current_system_message(&self) -> Option<&str>
pub fn get_current_system_message(&self) -> Option<&str>
Get the current system message text for display.
Sourcepub fn clear_system_messages(&mut self)
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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