Trait RemoteClient

Source
pub trait RemoteClient {
    const API_URL: &'static str;
    const API_URL_ENV: &'static str;

    // Required methods
    fn remote(&self) -> Remote;
    fn client(&self) -> ClientWithMiddleware;

    // Provided methods
    fn api_url(&self) -> String { ... }
    fn early_exit<T: DeserializeOwned + RemoteEntry>(&self, page: &T) -> bool { ... }
    async fn get_entry<T: DeserializeOwned + RemoteEntry>(
        &self,
        project_id: i64,
        ref_name: Option<&str>,
        page: i32,
    ) -> Result<T> { ... }
    async fn get_entries_with_page<T: DeserializeOwned + RemoteEntry>(
        &self,
        project_id: i64,
        ref_name: Option<&str>,
        page: i32,
    ) -> Result<Vec<T>> { ... }
    async fn fetch<T: DeserializeOwned + RemoteEntry>(
        &self,
        project_id: i64,
        ref_name: Option<&str>,
    ) -> Result<Vec<T>> { ... }
    async fn fetch_with_early_exit<T: DeserializeOwned + RemoteEntry>(
        &self,
        project_id: i64,
        ref_name: Option<&str>,
    ) -> Result<Vec<T>> { ... }
}
Available on crate feature remote only.
Expand description

Trait for handling the API connection and fetching.

Required Associated Constants§

Source

const API_URL: &'static str

API URL for a particular client

Source

const API_URL_ENV: &'static str

Name of the environment variable used to set the API URL to a self-hosted instance (if applicable).

Required Methods§

Source

fn remote(&self) -> Remote

Returns the remote repository information.

Source

fn client(&self) -> ClientWithMiddleware

Returns the HTTP client for making requests.

Provided Methods§

Source

fn api_url(&self) -> String

Returns the API url.

Source

fn early_exit<T: DeserializeOwned + RemoteEntry>(&self, page: &T) -> bool

Returns true if the client should early exit.

Source

async fn get_entry<T: DeserializeOwned + RemoteEntry>( &self, project_id: i64, ref_name: Option<&str>, page: i32, ) -> Result<T>

Retrieves a single object.

Source

async fn get_entries_with_page<T: DeserializeOwned + RemoteEntry>( &self, project_id: i64, ref_name: Option<&str>, page: i32, ) -> Result<Vec<T>>

Retrieves a single page of entries.

Source

async fn fetch<T: DeserializeOwned + RemoteEntry>( &self, project_id: i64, ref_name: Option<&str>, ) -> Result<Vec<T>>

Fetches the remote API and returns the given entry.

See fetch_with_early_exit for the early exit version of this method.

Source

async fn fetch_with_early_exit<T: DeserializeOwned + RemoteEntry>( &self, project_id: i64, ref_name: Option<&str>, ) -> Result<Vec<T>>

Fetches the remote API and returns the given entry.

Early exits based on the response.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl RemoteClient for BitbucketClient

Available on crate feature bitbucket only.
Source§

const API_URL: &'static str = "https://api.bitbucket.org/2.0/repositories"

Source§

const API_URL_ENV: &'static str = "BITBUCKET_API_URL"

Source§

impl RemoteClient for GiteaClient

Available on crate feature gitea only.
Source§

const API_URL: &'static str = "https://codeberg.org"

Source§

const API_URL_ENV: &'static str = "GITEA_API_URL"

Source§

impl RemoteClient for GitHubClient

Available on crate feature github only.
Source§

const API_URL: &'static str = "https://api.github.com"

Source§

const API_URL_ENV: &'static str = "GITHUB_API_URL"

Source§

impl RemoteClient for GitLabClient

Available on crate feature gitlab only.
Source§

const API_URL: &'static str = "https://gitlab.com/api/v4"

Source§

const API_URL_ENV: &'static str = "GITLAB_API_URL"