Skip to main content

mesa_dev/models/
mod.rs

1//! API model types.
2//!
3//! This module contains all request and response types used by the SDK.
4//! Response types are deserialized from JSON automatically. Request types
5//! are serialized to JSON when passed to resource methods.
6//!
7//! # Pagination
8//!
9//! List responses (e.g., [`ListReposResponse`]) implement the [`Paginated`]
10//! trait, which is used by [`PageStream`](crate::PageStream) to automatically
11//! iterate through all pages.
12
13mod admin;
14mod branch;
15mod commit;
16mod common;
17mod content;
18mod diff;
19mod lfs;
20pub mod pagination;
21mod repo;
22
23pub use admin::{ApiKey, ApiKeyCreated, ApiKeyScope, CreateApiKeyRequest, ListApiKeysResponse};
24pub use branch::{Branch, CreateBranchRequest, ListBranchesResponse};
25pub use commit::{
26    Author, Commit, CommitFile, CommitFileAction, CommitFileChange, CommitSummary,
27    CreateCommitRequest, CreateCommitWithLfsRequest, ListCommitsResponse,
28};
29pub use common::SuccessResponse;
30pub use content::{Content, DirEntry, DirEntryType};
31pub use diff::{Diff, DiffFile, DiffStats};
32pub use lfs::{
33    CommitLfsFile, LfsFileRef, LfsObjectError, LfsObjectSpec, LfsObjectStatus,
34    UploadLfsObjectsRequest, UploadLfsObjectsResponse,
35};
36pub use pagination::{Paginated, PaginationParams};
37pub use repo::{CreateRepoRequest, ListReposResponse, RenameRepoRequest, Repo};
38
39// ── Paginated trait implementations ──
40
41impl Paginated for ListReposResponse {
42    type Item = Repo;
43
44    fn items(self) -> Vec<Self::Item> {
45        self.repos
46    }
47
48    fn next_cursor(&self) -> Option<&str> {
49        self.next_cursor.as_deref()
50    }
51
52    fn has_more(&self) -> bool {
53        self.has_more
54    }
55}
56
57impl Paginated for ListBranchesResponse {
58    type Item = Branch;
59
60    fn items(self) -> Vec<Self::Item> {
61        self.branches
62    }
63
64    fn next_cursor(&self) -> Option<&str> {
65        self.next_cursor.as_deref()
66    }
67
68    fn has_more(&self) -> bool {
69        self.has_more
70    }
71}
72
73impl Paginated for ListCommitsResponse {
74    type Item = CommitSummary;
75
76    fn items(self) -> Vec<Self::Item> {
77        self.commits
78    }
79
80    fn next_cursor(&self) -> Option<&str> {
81        self.next_cursor.as_deref()
82    }
83
84    fn has_more(&self) -> bool {
85        self.has_more
86    }
87}