Skip to main content

mesa_dev/client/
content.rs

1use crate::low_level::apis::Error;
2use crate::low_level::content;
3
4use super::RepoClient;
5
6/// Client for content operations (`/{org}/{repo}/content`).
7#[derive(Clone, Debug)]
8pub struct ContentClient<'a> {
9    pub(super) repo: &'a RepoClient<'a>,
10}
11
12impl ContentClient<'_> {
13    /// Get file content or directory listing at a path.
14    ///
15    /// Uses the hand-written implementation for correct `anyOf` handling.
16    ///
17    /// # Errors
18    ///
19    /// Returns an error if the API request fails.
20    #[tracing::instrument(skip(self), fields(org = self.repo.org.org, repo = self.repo.repo), err(Debug))]
21    pub async fn get(
22        &self,
23        r#ref: Option<&str>,
24        path: Option<&str>,
25        depth: Option<u64>,
26    ) -> Result<content::Content, Error<content::GetContentError>> {
27        content::get_content(
28            self.repo.org.config,
29            self.repo.org.org,
30            self.repo.repo,
31            r#ref,
32            path,
33            depth,
34        )
35        .await
36    }
37}