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;
19pub mod pagination;
20mod repo;
21
22pub use admin::{ApiKey, ApiKeyCreated, ApiKeyScope, CreateApiKeyRequest, ListApiKeysResponse};
23pub use branch::{Branch, CreateBranchRequest, ListBranchesResponse};
24pub use commit::{
25    Author, Commit, CommitFile, CommitFileAction, CommitSummary, CreateCommitRequest,
26    ListCommitsResponse,
27};
28pub use common::SuccessResponse;
29pub use content::{Content, DirEntry, DirEntryType};
30pub use diff::{Diff, DiffFile, DiffStats};
31pub use pagination::{Paginated, PaginationParams};
32pub use repo::{CreateRepoRequest, ListReposResponse, RenameRepoRequest, Repo};
33
34// ── Paginated trait implementations ──
35
36impl Paginated for ListReposResponse {
37    type Item = Repo;
38
39    fn items(self) -> Vec<Self::Item> {
40        self.repos
41    }
42
43    fn next_cursor(&self) -> Option<&str> {
44        self.next_cursor.as_deref()
45    }
46
47    fn has_more(&self) -> bool {
48        self.has_more
49    }
50}
51
52impl Paginated for ListBranchesResponse {
53    type Item = Branch;
54
55    fn items(self) -> Vec<Self::Item> {
56        self.branches
57    }
58
59    fn next_cursor(&self) -> Option<&str> {
60        self.next_cursor.as_deref()
61    }
62
63    fn has_more(&self) -> bool {
64        self.has_more
65    }
66}
67
68impl Paginated for ListCommitsResponse {
69    type Item = CommitSummary;
70
71    fn items(self) -> Vec<Self::Item> {
72        self.commits
73    }
74
75    fn next_cursor(&self) -> Option<&str> {
76        self.next_cursor.as_deref()
77    }
78
79    fn has_more(&self) -> bool {
80        self.has_more
81    }
82}