pub struct ThreadNode {
pub post: Rc<RefCell<Post>>,
pub replies: Vec<ThreadNode>,
pub depth: usize,
pub latest_activity_time: Option<DateTime<FixedOffset>>,
}Expand description
Represents a node in a threaded conversation tree.
Fields§
§post: Rc<RefCell<Post>>The post at this node
replies: Vec<ThreadNode>Direct replies to this post
depth: usizeDepth level in the conversation (0 = root)
latest_activity_time: Option<DateTime<FixedOffset>>Latest activity time in this node’s subtree (including this post and all replies)
Implementations§
Source§impl ThreadNode
impl ThreadNode
pub fn new(post: Rc<RefCell<Post>>, depth: usize) -> Self
pub fn add_reply(&mut self, reply_node: ThreadNode)
Sourcepub fn update_latest_activity_time(&mut self)
pub fn update_latest_activity_time(&mut self)
Calculate and update the latest activity time for this node and all its descendants. This should be called after the tree structure is complete.
pub fn sort_replies(&mut self)
pub fn count_posts(&self) -> usize
pub fn flatten(&self) -> Vec<&Rc<RefCell<Post>>>
Trait Implementations§
Source§impl Clone for ThreadNode
impl Clone for ThreadNode
Source§fn clone(&self) -> ThreadNode
fn clone(&self) -> ThreadNode
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for ThreadNode
impl !Send for ThreadNode
impl !Sync for ThreadNode
impl !UnwindSafe for ThreadNode
impl Freeze for ThreadNode
impl Unpin for ThreadNode
impl UnsafeUnpin for ThreadNode
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
Mutably borrows from an owned value. Read more