pub struct CodecovClient { /* private fields */ }Implementations§
Source§impl CodecovClient
impl CodecovClient
Sourcepub fn new(
token: impl Into<String>,
api_base: impl Into<String>,
) -> Result<Self, ClientError>
pub fn new( token: impl Into<String>, api_base: impl Into<String>, ) -> Result<Self, ClientError>
Builds a client with an explicit token and API base URL.
§Errors
Returns ClientError::MissingToken for an empty token,
ClientError::InvalidAuthHeader for an invalid Bearer token or Authorization header,
or ClientError::Http if the HTTP client cannot be constructed.
Sourcepub fn from_env() -> Result<Self, ClientError>
pub fn from_env() -> Result<Self, ClientError>
Builds a client from CODECOV_TOKEN and optional CODECOV_API_URL.
Loads an optional .env file first (does not override existing process env).
§Errors
Returns a client construction error when the token is missing or invalid.
Sourcepub fn totals_url(
api_base: &str,
owner: &str,
repo: &str,
branch: Option<&str>,
sha: Option<&str>,
) -> String
pub fn totals_url( api_base: &str, owner: &str, repo: &str, branch: Option<&str>, sha: Option<&str>, ) -> String
Builds the totals URL for a GitHub repo.
Sourcepub fn file_report_url(
api_base: &str,
owner: &str,
repo: &str,
path: &str,
branch: Option<&str>,
sha: Option<&str>,
) -> String
pub fn file_report_url( api_base: &str, owner: &str, repo: &str, path: &str, branch: Option<&str>, sha: Option<&str>, ) -> String
Builds the file report URL for a path inside a GitHub repo.
Sourcepub fn pull_comparison_url(
api_base: &str,
owner: &str,
repo: &str,
pull_id: u64,
) -> String
pub fn pull_comparison_url( api_base: &str, owner: &str, repo: &str, pull_id: u64, ) -> String
Builds the Codecov pull comparison URL for a pull request.
Sourcepub async fn totals(
&self,
owner: &str,
repo: &str,
branch: Option<&str>,
sha: Option<&str>,
) -> Result<CoverageReport, ClientError>
pub async fn totals( &self, owner: &str, repo: &str, branch: Option<&str>, sha: Option<&str>, ) -> Result<CoverageReport, ClientError>
Fetches commit coverage totals (including per-file breakdown).
§Errors
Returns ClientError::Http, ClientError::Api, or ClientError::Json.
Sourcepub async fn miss_files(
&self,
owner: &str,
repo: &str,
branch: Option<&str>,
sha: Option<&str>,
limit: usize,
) -> Result<MissFilesResult, ClientError>
pub async fn miss_files( &self, owner: &str, repo: &str, branch: Option<&str>, sha: Option<&str>, limit: usize, ) -> Result<MissFilesResult, ClientError>
Files with misses, sorted descending, capped by limit (0 = uncapped).
The complete totals report is fetched from Codecov before filtering;
limit controls only the number of files returned by this method.
§Errors
Same as Self::totals.
Sourcepub async fn file_report(
&self,
owner: &str,
repo: &str,
path: &str,
branch: Option<&str>,
sha: Option<&str>,
) -> Result<ReportFile, ClientError>
pub async fn file_report( &self, owner: &str, repo: &str, path: &str, branch: Option<&str>, sha: Option<&str>, ) -> Result<ReportFile, ClientError>
Sourcepub async fn pull_report(
&self,
owner: &str,
repo: &str,
pull_id: u64,
) -> Result<PullCoverageReport, ClientError>
pub async fn pull_report( &self, owner: &str, repo: &str, pull_id: u64, ) -> Result<PullCoverageReport, ClientError>
Fetches a pull request’s Codecov patch comparison and missed changed lines.
§Errors
Returns ClientError::Http, ClientError::Api, or ClientError::Json.