Skip to main content

TopicBehavior

Trait TopicBehavior 

Source
pub trait TopicBehavior {
    // Required methods
    fn list_topics(
        &self,
        limit: Option<u32>,
        tags: &[String],
        tag_mode: Option<&str>,
        cursor: Option<&str>,
    ) -> impl Future<Output = Result<CursorListDTO<TopicListItemDTO>, Error>> + Send;
    fn get_topic_recommendations(
        &self,
        sort: Option<&str>,
        limit: Option<u32>,
        cursor: Option<&str>,
    ) -> impl Future<Output = Result<TopicRecommendationsDTO, Error>> + Send;
    fn get_topic(
        &self,
        topic_id: &str,
    ) -> impl Future<Output = Result<TopicDetailDTO, Error>> + Send;
    fn get_topic_posts(
        &self,
        topic_id: &str,
        limit: Option<u32>,
        sort: Option<&str>,
        cursor: Option<&str>,
    ) -> impl Future<Output = Result<CursorListDTO<TopicPostDTO>, Error>> + Send;
    fn create_topic(
        &self,
        idempotency_key: &str,
        title: &str,
        markdown: &str,
        kind: &str,
        tag_ids: Vec<String>,
    ) -> impl Future<Output = Result<CreatePostResponseDTO, Error>> + Send;
    fn create_reply(
        &self,
        idempotency_key: &str,
        topic_id: &str,
        markdown: &str,
        reply_to_post_number: Option<u64>,
    ) -> impl Future<Output = Result<CreatePostResponseDTO, Error>> + Send;
    fn list_post_submissions(
        &self,
        content_role: Option<&str>,
        status: Option<&str>,
        topic_id: Option<&str>,
        limit: Option<u32>,
        cursor: Option<&str>,
    ) -> impl Future<Output = Result<CursorListDTO<PostSubmissionDTO>, Error>> + Send;
    fn get_post_submission(
        &self,
        submission_id: &str,
    ) -> impl Future<Output = Result<PostSubmissionDTO, Error>> + Send;
}
Expand description

主题与内容接口,来自文档的「主题与内容」章节 (https://pickcat-docs.xiaole6324.fun/topic.html)。

Required Methods§

Source

fn list_topics( &self, limit: Option<u32>, tags: &[String], tag_mode: Option<&str>, cursor: Option<&str>, ) -> impl Future<Output = Result<CursorListDTO<TopicListItemDTO>, Error>> + Send

GET /api/v1/topics —— 公开。tags 中的每个标签都会作为独立的 tag 参数重复传入;tag_mode 通常为 all。

Source

fn get_topic_recommendations( &self, sort: Option<&str>, limit: Option<u32>, cursor: Option<&str>, ) -> impl Future<Output = Result<TopicRecommendationsDTO, Error>> + Send

GET /api/v1/topic-recommendations —— 公开。

Source

fn get_topic( &self, topic_id: &str, ) -> impl Future<Output = Result<TopicDetailDTO, Error>> + Send

GET /api/v1/topics/{topicId} —— 公开。

Source

fn get_topic_posts( &self, topic_id: &str, limit: Option<u32>, sort: Option<&str>, cursor: Option<&str>, ) -> impl Future<Output = Result<CursorListDTO<TopicPostDTO>, Error>> + Send

GET /api/v1/topics/{topicId}/posts —— 公开,游标分页。

Source

fn create_topic( &self, idempotency_key: &str, title: &str, markdown: &str, kind: &str, tag_ids: Vec<String>, ) -> impl Future<Output = Result<CreatePostResponseDTO, Error>> + Send

POST /api/v1/posts —— 需要会话,发布主题首楼。

idempotency_key 会作为必填的 Idempotency-Key 请求头发送;可用 generate_idempotency_key 生成。成功返回 202(异步审核)。

Source

fn create_reply( &self, idempotency_key: &str, topic_id: &str, markdown: &str, reply_to_post_number: Option<u64>, ) -> impl Future<Output = Result<CreatePostResponseDTO, Error>> + Send

POST /api/v1/posts —— 需要会话,发布回帖(可楼中楼)。

Source

fn list_post_submissions( &self, content_role: Option<&str>, status: Option<&str>, topic_id: Option<&str>, limit: Option<u32>, cursor: Option<&str>, ) -> impl Future<Output = Result<CursorListDTO<PostSubmissionDTO>, Error>> + Send

GET /api/v1/post-submissions —— 需要会话,投稿审核列表。

Source

fn get_post_submission( &self, submission_id: &str, ) -> impl Future<Output = Result<PostSubmissionDTO, Error>> + Send

GET /api/v1/post-submissions/{submissionId} —— 需要会话。

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§