pub struct PickcatAccound {
pub username: String,
pub password: String,
pub client: Client,
pub base_url: String,
}Expand description
已登录的 Pickcat 账号,是访问所有接口的入口。
构造时即完成登录并保存会话 Cookie;各章节的方法由对应 trait 提供 (见 crate 文档的表格)。
Fields§
§username: String§password: String§client: Client§base_url: StringAPI 根地址;默认 https://cdsq.dao3.fun,测试时可注入 mock server。
Implementations§
Trait Implementations§
Source§impl Debug for PickcatAccound
impl Debug for PickcatAccound
Source§impl MediaBehavior for PickcatAccound
impl MediaBehavior for PickcatAccound
Source§async fn upload_file(
&self,
idempotency_key: &str,
ownership: &str,
file_name: &str,
bytes: Vec<u8>,
) -> Result<UploadedFileDTO, Error>
async fn upload_file( &self, idempotency_key: &str, ownership: &str, file_name: &str, bytes: Vec<u8>, ) -> Result<UploadedFileDTO, Error>
Source§async fn list_files(
&self,
scope: Option<&str>,
state: Option<&str>,
limit: Option<u32>,
cursor: Option<&str>,
) -> Result<FileListDTO, Error>
async fn list_files( &self, scope: Option<&str>, state: Option<&str>, limit: Option<u32>, cursor: Option<&str>, ) -> Result<FileListDTO, Error>
GET /api/v1/files —— 需要会话,游标分页。Source§async fn get_file(&self, file_id: &str) -> Result<Vec<u8>, Error>
async fn get_file(&self, file_id: &str) -> Result<Vec<u8>, Error>
GET /api/v1/files/{fileId} —— 公开,返回图片字节。Source§impl NotificationBehavior for PickcatAccound
impl NotificationBehavior for PickcatAccound
Source§async fn get_notification_summary(
&self,
) -> Result<NotificationSummaryDTO, Error>
async fn get_notification_summary( &self, ) -> Result<NotificationSummaryDTO, Error>
GET /api/v1/notification-summary —— 需要会话,首页轮询用。Source§impl ReadingSessionBehavior for PickcatAccound
impl ReadingSessionBehavior for PickcatAccound
Source§async fn report_reading_batch(
&self,
session_id: &str,
batch_no: u32,
topic_id: &str,
elapsed_ms: u64,
visible_posts: Vec<VisiblePostDTO>,
) -> Result<ReadingBatchResponseDTO, Error>
async fn report_reading_batch( &self, session_id: &str, batch_no: u32, topic_id: &str, elapsed_ms: u64, visible_posts: Vec<VisiblePostDTO>, ) -> Result<ReadingBatchResponseDTO, Error>
PUT /api/v1/reading-sessions/{sessionId}/batches/{batchNo} —— 需要会话。 Read moreSource§impl TagBehavior for PickcatAccound
impl TagBehavior for PickcatAccound
GET /api/v1/tags —— 公开。assignable = true 时只返回可发帖分区。GET /api/v1/tags/{slug}/sidebar-links —— 公开。Source§impl TopicBehavior for PickcatAccound
impl TopicBehavior for PickcatAccound
Source§async fn list_topics(
&self,
limit: Option<u32>,
tags: &[String],
tag_mode: Option<&str>,
cursor: Option<&str>,
) -> Result<CursorListDTO<TopicListItemDTO>, Error>
async fn list_topics( &self, limit: Option<u32>, tags: &[String], tag_mode: Option<&str>, cursor: Option<&str>, ) -> Result<CursorListDTO<TopicListItemDTO>, Error>
GET /api/v1/topics —— 公开。tags 中的每个标签都会作为独立的
tag 参数重复传入;tag_mode 通常为 all。Source§async fn get_topic_recommendations(
&self,
sort: Option<&str>,
limit: Option<u32>,
cursor: Option<&str>,
) -> Result<TopicRecommendationsDTO, Error>
async fn get_topic_recommendations( &self, sort: Option<&str>, limit: Option<u32>, cursor: Option<&str>, ) -> Result<TopicRecommendationsDTO, Error>
GET /api/v1/topic-recommendations —— 公开。Source§async fn get_topic(&self, topic_id: &str) -> Result<TopicDetailDTO, Error>
async fn get_topic(&self, topic_id: &str) -> Result<TopicDetailDTO, Error>
GET /api/v1/topics/{topicId} —— 公开。Source§async fn get_topic_posts(
&self,
topic_id: &str,
limit: Option<u32>,
sort: Option<&str>,
cursor: Option<&str>,
) -> Result<CursorListDTO<TopicPostDTO>, Error>
async fn get_topic_posts( &self, topic_id: &str, limit: Option<u32>, sort: Option<&str>, cursor: Option<&str>, ) -> Result<CursorListDTO<TopicPostDTO>, Error>
GET /api/v1/topics/{topicId}/posts —— 公开,游标分页。Source§async fn create_topic(
&self,
idempotency_key: &str,
title: &str,
markdown: &str,
kind: &str,
tag_ids: Vec<String>,
) -> Result<CreatePostResponseDTO, Error>
async fn create_topic( &self, idempotency_key: &str, title: &str, markdown: &str, kind: &str, tag_ids: Vec<String>, ) -> Result<CreatePostResponseDTO, Error>
POST /api/v1/posts —— 需要会话,发布主题首楼。 Read moreSource§async fn create_reply(
&self,
idempotency_key: &str,
topic_id: &str,
markdown: &str,
reply_to_post_number: Option<u64>,
) -> Result<CreatePostResponseDTO, Error>
async fn create_reply( &self, idempotency_key: &str, topic_id: &str, markdown: &str, reply_to_post_number: Option<u64>, ) -> Result<CreatePostResponseDTO, Error>
POST /api/v1/posts —— 需要会话,发布回帖(可楼中楼)。Source§async fn list_post_submissions(
&self,
content_role: Option<&str>,
status: Option<&str>,
topic_id: Option<&str>,
limit: Option<u32>,
cursor: Option<&str>,
) -> Result<CursorListDTO<PostSubmissionDTO>, Error>
async fn list_post_submissions( &self, content_role: Option<&str>, status: Option<&str>, topic_id: Option<&str>, limit: Option<u32>, cursor: Option<&str>, ) -> Result<CursorListDTO<PostSubmissionDTO>, Error>
GET /api/v1/post-submissions —— 需要会话,投稿审核列表。Source§async fn get_post_submission(
&self,
submission_id: &str,
) -> Result<PostSubmissionDTO, Error>
async fn get_post_submission( &self, submission_id: &str, ) -> Result<PostSubmissionDTO, Error>
GET /api/v1/post-submissions/{submissionId} —— 需要会话。Source§impl UserBehavior for PickcatAccound
impl UserBehavior for PickcatAccound
async fn get_current_user_session(&self) -> Result<SessionDTO, Error>
async fn post_registration( &self, username: &str, email: &str, captcha: &str, ) -> Result<RegistrationDTO, Error>
async fn verify_email( &self, code: &str, password: &str, id: &str, ) -> Result<VerifyEmailDTO, Error>
async fn get_exam_status(&self) -> Result<ExamStatusDTO, Error>
async fn start_exam(&self) -> Result<StartExamDTO, Error>
async fn get_current_question( &self, id: &str, ) -> Result<CurrentQuestionDTO, Error>
async fn submit_answer( &self, exam_id: &str, question_id: &str, token: &str, selected_option_ids: Vec<String>, ) -> Result<SubmitExamAnswerResponseDTO, Error>
Source§impl UserProfileBehavior for PickcatAccound
impl UserProfileBehavior for PickcatAccound
Source§async fn get_user_information(
&self,
user_id: &str,
) -> Result<GetUserInformationDTO, Error>
async fn get_user_information( &self, user_id: &str, ) -> Result<GetUserInformationDTO, Error>
GET /api/v1/users/{userId} — public, works with or without a session.Source§async fn update_user_profile(
&self,
user_id: &str,
bio: Option<&str>,
) -> Result<GetUserInformationDTO, Error>
async fn update_user_profile( &self, user_id: &str, bio: Option<&str>, ) -> Result<GetUserInformationDTO, Error>
PATCH /api/v1/users/{userId} — requires a session; only the current
user may edit their own profile. None fields are left unchanged.Source§async fn get_user_email(&self, user_id: &str) -> Result<GetUserEmailDTO, Error>
async fn get_user_email(&self, user_id: &str) -> Result<GetUserEmailDTO, Error>
GET /api/v1/users/{userId}/email — requires a session and only works
for the current user.Source§async fn get_user_following(
&self,
user_id: &str,
limit: Option<u32>,
cursor: Option<&str>,
) -> Result<CursorListDTO<GetUserInformationDTO>, Error>
async fn get_user_following( &self, user_id: &str, limit: Option<u32>, cursor: Option<&str>, ) -> Result<CursorListDTO<GetUserInformationDTO>, Error>
GET /api/v1/users/{userId}/following — public, cursor-paginated.Source§async fn get_user_followers(
&self,
user_id: &str,
limit: Option<u32>,
cursor: Option<&str>,
) -> Result<CursorListDTO<GetUserInformationDTO>, Error>
async fn get_user_followers( &self, user_id: &str, limit: Option<u32>, cursor: Option<&str>, ) -> Result<CursorListDTO<GetUserInformationDTO>, Error>
GET /api/v1/users/{userId}/followers — public, cursor-paginated.Source§async fn get_user_topics(
&self,
user_id: &str,
limit: Option<u32>,
) -> Result<UserSubjectsDTO, Error>
async fn get_user_topics( &self, user_id: &str, limit: Option<u32>, ) -> Result<UserSubjectsDTO, Error>
GET /api/v1/users/{userId}/topics — public, cursor-paginated.Source§async fn get_user_posts(
&self,
user_id: &str,
role: Option<&str>,
limit: Option<u32>,
) -> Result<UserRepliesDTO, Error>
async fn get_user_posts( &self, user_id: &str, role: Option<&str>, limit: Option<u32>, ) -> Result<UserRepliesDTO, Error>
GET /api/v1/users/{userId}/posts?role=reply — public, cursor-paginated.Source§async fn get_user_featured_topics(
&self,
user_id: &str,
) -> Result<UserFeaturedTopicsDTO, Error>
async fn get_user_featured_topics( &self, user_id: &str, ) -> Result<UserFeaturedTopicsDTO, Error>
GET /api/v1/users/{userId}/featured-topics — public, no pagination.Source§async fn get_user_topic_collections(
&self,
user_id: &str,
limit: Option<u32>,
) -> Result<CursorListDTO<Value>, Error>
async fn get_user_topic_collections( &self, user_id: &str, limit: Option<u32>, ) -> Result<CursorListDTO<Value>, Error>
GET /api/v1/users/{userId}/topic-collections — public, paginated. Read moreSource§async fn get_user_badges(&self, user_id: &str) -> Result<UserBadgesDTO, Error>
async fn get_user_badges(&self, user_id: &str) -> Result<UserBadgesDTO, Error>
GET /api/v1/users/{userId}/badges — public.Source§async fn get_user_badge_display(
&self,
user_id: &str,
) -> Result<BadgeDisplayDTO, Error>
async fn get_user_badge_display( &self, user_id: &str, ) -> Result<BadgeDisplayDTO, Error>
GET /api/v1/users/{userId}/badge-display — public.Source§async fn get_user_badge_displays(
&self,
user_ids: &[String],
) -> Result<UserBadgeDisplaysDTO, Error>
async fn get_user_badge_displays( &self, user_ids: &[String], ) -> Result<UserBadgeDisplaysDTO, Error>
GET /api/v1/user-badge-displays?userIds=a,b — public bulk lookup.Source§async fn get_user_profile_activities(
&self,
user_id: &str,
year: Option<u32>,
limit: Option<u32>,
) -> Result<CursorListDTO<ProfileActivityDTO>, Error>
async fn get_user_profile_activities( &self, user_id: &str, year: Option<u32>, limit: Option<u32>, ) -> Result<CursorListDTO<ProfileActivityDTO>, Error>
GET /api/v1/users/{userId}/profile-activities — public, paginated.Source§async fn get_my_profile_activities(
&self,
year: Option<u32>,
limit: Option<u32>,
) -> Result<CursorListDTO<ProfileActivityDTO>, Error>
async fn get_my_profile_activities( &self, year: Option<u32>, limit: Option<u32>, ) -> Result<CursorListDTO<ProfileActivityDTO>, Error>
GET /api/v1/profile-activities — requires a session.Source§async fn get_user_level_contributions(
&self,
user_id: &str,
year: u32,
) -> Result<LevelContributionsDTO, Error>
async fn get_user_level_contributions( &self, user_id: &str, year: u32, ) -> Result<LevelContributionsDTO, Error>
GET /api/v1/users/{userId}/level-contributions/{year} — public.Source§async fn get_my_level_contributions(
&self,
year: u32,
) -> Result<LevelContributionsDTO, Error>
async fn get_my_level_contributions( &self, year: u32, ) -> Result<LevelContributionsDTO, Error>
GET /api/v1/level-contributions/{year} — requires a session.Source§async fn get_level_progress(&self) -> Result<LevelProgressDTO, Error>
async fn get_level_progress(&self) -> Result<LevelProgressDTO, Error>
GET /api/v1/level-progress — requires a session.Source§async fn get_content_length_limit(&self) -> Result<ContentLengthLimitDTO, Error>
async fn get_content_length_limit(&self) -> Result<ContentLengthLimitDTO, Error>
GET /api/v1/content-length-limit — requires a session.Source§async fn get_topic_collection_usage(
&self,
) -> Result<TopicCollectionUsageDTO, Error>
async fn get_topic_collection_usage( &self, ) -> Result<TopicCollectionUsageDTO, Error>
GET /api/v1/topic-collection-usage — requires a session.Source§async fn get_file_storage(&self) -> Result<FileStorageDTO, Error>
async fn get_file_storage(&self) -> Result<FileStorageDTO, Error>
GET /api/v1/file-storage — requires a session.Source§async fn get_bookmarks(
&self,
limit: Option<u32>,
) -> Result<CursorListDTO<Value>, Error>
async fn get_bookmarks( &self, limit: Option<u32>, ) -> Result<CursorListDTO<Value>, Error>
GET /api/v1/bookmarks — requires a session, paginated. Read moreSource§async fn get_avatar_presets(&self) -> Result<AvatarPresetsDTO, Error>
async fn get_avatar_presets(&self) -> Result<AvatarPresetsDTO, Error>
GET /api/v1/avatar-presets — public.Auto Trait Implementations§
impl !RefUnwindSafe for PickcatAccound
impl !UnwindSafe for PickcatAccound
impl Freeze for PickcatAccound
impl Send for PickcatAccound
impl Sync for PickcatAccound
impl Unpin for PickcatAccound
impl UnsafeUnpin for PickcatAccound
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