pub struct Threads<C: CommentModel> { /* private fields */ }Expand description
A query for threads, from CommentModel::threads or CommentModel::thread_tree.
let page = Comment::threads(post)
.sort(Sort::Best)
.depth(3)
.viewer(&viewer)
.page(2)
.get()
.await?;Implementations§
Source§impl<C: CommentModel> Threads<C>
impl<C: CommentModel> Threads<C>
Sourcepub fn sort(self, sort: Sort) -> Self
pub fn sort(self, sort: Sort) -> Self
The order of top-level comments and of replies. Oldest first by default.
Sourcepub fn depth(self, depth: i64) -> Self
pub fn depth(self, depth: i64) -> Self
Loads replies down to this depth, where top-level comments are 0. A comment at that
depth reports its other replies in more_replies. Every level by default.
Sourcepub fn viewer(self, viewer: &C::Author) -> Self
pub fn viewer(self, viewer: &C::Author) -> Self
The user whose reactions viewer_reactions lists.
Sourcepub async fn locate(&self, comment: &C) -> Result<Option<Location>>
pub async fn locate(&self, comment: &C) -> Result<Option<Location>>
Where comment shows on these pages: the page its thread is on, the thread’s top-level
comment, and, when the comment is deeper than depth, the comment whose
more_replies leads to it. None when its thread isn’t on these pages, as for a comment
on another model or in a thread with nothing approved. For a link to one comment, such as
in a notification, ask with the same sort, page size, and depth the page uses:
if let Some(place) = Comment::threads(post.clone()).sort(Sort::Best).depth(3).locate(&comment).await? {
let anchor = place.cut_at.unwrap_or(place.comment_id);
let url = format!("/posts/{}?sort=best&page={}#comment-{anchor}", post.id, place.page);
}The page comes from one query counting the threads before this one, so it’s right for
the order at the time of asking: with Sort::Best, new reactions may move a thread.
§Errors
Fails when a query fails.
Sourcepub async fn get(self) -> Result<ThreadPage<C>>
pub async fn get(self) -> Result<ThreadPage<C>>
Reads the page: a query counting the threads, one for the top-level comments, one for their replies, one for each eager-loaded author query, one for the reaction counts, and one for the viewer’s reactions, however many comments there are.
§Errors
Fails when a query fails.
Auto Trait Implementations§
impl<C> Forget for Threads<C>
impl<C> Freeze for Threads<C>where
<C as CommentModel>::Commentable: Freeze,
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
impl<C> Move for Threads<C>
impl<C> RefUnwindSafe for Threads<C>
impl<C> Send for Threads<C>
impl<C> Sync for Threads<C>
impl<C> Unpin for Threads<C>
impl<C> UnsafeUnpin for Threads<C>where
<C as CommentModel>::Commentable: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
impl<C> UnwindSafe for Threads<C>
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<K> ForeignKey<K> for K
impl<K> ForeignKey<K> for K
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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