Skip to main content

PickcatAccound

Struct PickcatAccound 

Source
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: String

API 根地址;默认 https://cdsq.dao3.fun,测试时可注入 mock server。

Implementations§

Source§

impl PickcatAccound

Source

pub async fn new(username: &str, password: &str) -> Result<Self, Error>

使用默认 API 根地址登录。

Source

pub async fn with_base_url( username: &str, password: &str, base_url: &str, ) -> Result<Self, Error>

与 PickcatAccound::new 相同,但可指定 API 根地址。

主要用于测试:把 base_url 指向 mock server 即可离线验证请求。

Trait Implementations§

Source§

impl Debug for PickcatAccound

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl MediaBehavior for PickcatAccound

Source§

async fn upload_file( &self, idempotency_key: &str, ownership: &str, file_name: &str, bytes: Vec<u8>, ) -> Result<UploadedFileDTO, Error>

POST /api/v1/files —— 需要会话,multipart/form-data。 Read more
Source§

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>

GET /api/v1/files/{fileId} —— 公开,返回图片字节。
Source§

async fn get_avatar( &self, id: &str, version: Option<&str>, ) -> Result<Vec<u8>, Error>

GET /api/v1/avatars/{id} —— 公开,id 为预设编号或自定义头像 fileId。
Source§

async fn get_emoji_image( &self, emoji_name: &str, emoji_read: Option<&str>, ) -> Result<Vec<u8>, Error>

GET /api/v1/emojis/{emojiName}/image —— 公开,返回表情图片字节。
Source§

impl NotificationBehavior for PickcatAccound

Source§

async fn get_notification_summary( &self, ) -> Result<NotificationSummaryDTO, Error>

GET /api/v1/notification-summary —— 需要会话,首页轮询用。
Source§

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>

PUT /api/v1/reading-sessions/{sessionId}/batches/{batchNo} —— 需要会话。 Read more
Source§

impl TagBehavior for PickcatAccound

Source§

async fn list_tags(&self, assignable: Option<bool>) -> Result<TagsDTO, Error>

GET /api/v1/tags —— 公开。assignable = true 时只返回可发帖分区。
GET /api/v1/tags/{slug}/sidebar-links —— 公开。
Source§

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>

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>

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

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>

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>

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

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>

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

async fn get_post_submission( &self, submission_id: &str, ) -> Result<PostSubmissionDTO, Error>

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

impl UserBehavior for PickcatAccound

Source§

async fn get_current_user_session(&self) -> Result<SessionDTO, Error>

Source§

async fn post_registration( &self, username: &str, email: &str, captcha: &str, ) -> Result<RegistrationDTO, Error>

Source§

async fn verify_email( &self, code: &str, password: &str, id: &str, ) -> Result<VerifyEmailDTO, Error>

Source§

async fn get_exam_status(&self) -> Result<ExamStatusDTO, Error>

Source§

async fn start_exam(&self) -> Result<StartExamDTO, Error>

Source§

async fn get_current_question( &self, id: &str, ) -> Result<CurrentQuestionDTO, Error>

Source§

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

Source§

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>

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>

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>

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>

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>

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>

GET /api/v1/users/{userId}/posts?role=reply — public, cursor-paginated.
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>

GET /api/v1/users/{userId}/topic-collections — public, paginated. Read more
Source§

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>

GET /api/v1/users/{userId}/badge-display — public.
Source§

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>

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>

GET /api/v1/profile-activities — requires a session.
Source§

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>

GET /api/v1/level-contributions/{year} — requires a session.
Source§

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>

GET /api/v1/content-length-limit — requires a session.
Source§

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>

GET /api/v1/file-storage — requires a session.
Source§

async fn get_bookmarks( &self, limit: Option<u32>, ) -> Result<CursorListDTO<Value>, Error>

GET /api/v1/bookmarks — requires a session, paginated. Read more
Source§

async fn get_avatar_presets(&self) -> Result<AvatarPresetsDTO, Error>

GET /api/v1/avatar-presets — public.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more