pub struct ConversationView {
pub peer: String,
pub messages: VecDeque<Message>,
pub scroll_offset: usize,
pub loaded_count: usize,
pub total_count: Option<usize>,
pub is_loading: bool,
pub has_more_history: bool,
pub oldest_timestamp: Option<u64>,
pub newest_timestamp: Option<u64>,
}Expand description
Manages a conversation with message history.
This struct handles lazy loading of message history with infinite scrolling. Messages are stored in a VecDeque for efficient prepending when loading older messages.
Fields§
§peer: StringUsername of the peer
messages: VecDeque<Message>Message cache (ordered by timestamp, oldest first)
scroll_offset: usizeCurrent scroll position (0 = bottom/newest)
loaded_count: usizeTotal messages loaded from storage
total_count: Option<usize>Total messages in storage (if known)
is_loading: boolWhether we’re currently loading history
has_more_history: boolWhether more history exists to load
oldest_timestamp: Option<u64>Timestamp of oldest loaded message
newest_timestamp: Option<u64>Timestamp of newest loaded message
Implementations§
Source§impl ConversationView
impl ConversationView
Sourcepub fn prepend_messages(&mut self, messages: Vec<Message>)
pub fn prepend_messages(&mut self, messages: Vec<Message>)
Add messages to the front (older messages).
Used when loading history backwards in time.
Sourcepub fn append_messages(&mut self, messages: Vec<Message>)
pub fn append_messages(&mut self, messages: Vec<Message>)
Add messages to the back (newer messages).
Used when initially loading recent messages or when receiving new messages.
Sourcepub fn add_message(&mut self, message: Message)
pub fn add_message(&mut self, message: Message)
Add a single new message (for real-time incoming messages).
Sourcepub fn get_oldest_timestamp(&self) -> Option<u64>
pub fn get_oldest_timestamp(&self) -> Option<u64>
Get oldest timestamp for pagination.
Sourcepub fn is_at_bottom(&self) -> bool
pub fn is_at_bottom(&self) -> bool
Check if we’re scrolled to the bottom.
Trait Implementations§
Source§impl Clone for ConversationView
impl Clone for ConversationView
Source§fn clone(&self) -> ConversationView
fn clone(&self) -> ConversationView
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ConversationView
impl RefUnwindSafe for ConversationView
impl Send for ConversationView
impl Sync for ConversationView
impl Unpin for ConversationView
impl UnwindSafe for ConversationView
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§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