Skip to main content

RepoBuilder

Struct RepoBuilder 

Source
pub struct RepoBuilder { /* private fields */ }
Expand description

Builder-pattern API for constructing a Repo with a fluent interface.

Create a new builder with RepoBuilder::new or clone an existing repo with RepoBuilder::from.

§Examples

use dnf_repofile::{RepoBuilder, RepoId, DnfBool};

let repo = RepoBuilder::new(RepoId::try_new("myrepo").unwrap())
    .enabled(DnfBool::yes())
    .build();

Implementations§

Source§

impl RepoBuilder

Source

pub fn new(id: RepoId) -> Self

Create a new builder with the given repository ID.

All other fields are initialized to None or empty.

§Examples
use dnf_repofile::{RepoBuilder, RepoId};

let builder = RepoBuilder::new(RepoId::try_new("test").unwrap());
Source

pub fn from(existing: &Repo) -> Self

Create a builder pre-populated from an existing Repo.

Useful for making a modified copy of an existing configuration.

§Examples
use dnf_repofile::{RepoBuilder, Repo, RepoId};

let original = Repo::new(RepoId::try_new("test").unwrap());
let builder = RepoBuilder::from(&original);
Source

pub fn build(self) -> Repo

Consume the builder and produce the final Repo.

§Examples
use dnf_repofile::{RepoBuilder, RepoId};

let repo = RepoBuilder::new(RepoId::try_new("test").unwrap()).build();
Source

pub fn name(self, v: RepoName) -> Self

Set the human-readable repository name.

Source

pub fn baseurl(self, v: Url) -> Self

Add a base URL to the repository.

Multiple URLs can be added by chaining this method.

Source

pub fn baseurls(self, v: Vec<Url>) -> Self

Set all base URLs at once, replacing any existing URLs.

Source

pub fn mirrorlist(self, v: Url) -> Self

Set the mirror list URL.

Set the metalink URL.

Source

pub fn gpgkey(self, v: &str) -> Self

Add a GPG key URL.

Multiple keys can be added by chaining this method.

Source

pub fn gpgkeys(self, v: Vec<String>) -> Self

Set all GPG key URLs at once, replacing any existing keys.

Source

pub fn enabled(self, v: DnfBool) -> Self

Set whether the repository is enabled.

Source

pub fn gpgcheck(self, v: DnfBool) -> Self

Set whether to GPG-check packages from this repo.

Source

pub fn repo_gpgcheck(self, v: DnfBool) -> Self

Set whether to GPG-check repository metadata.

Source

pub fn priority(self, v: Priority) -> Self

Set the repository priority (1–99, lower = higher priority).

Source

pub fn cost(self, v: Cost) -> Self

Set the repository cost (higher = less preferred).

Source

pub fn module_hotfixes(self, v: DnfBool) -> Self

Mark the repository as a module hotfix repository.

Source

pub fn metadata_type(self, v: RepoMetadataType) -> Self

Set the repository metadata type (e.g., rpm-md).

Source

pub fn mediaid(self, v: &str) -> Self

Set the media ID for DVD/media-based repositories.

Source

pub fn excludepkgs(self, v: &str) -> Self

Add a package name glob to the exclude list.

Source

pub fn includepkgs(self, v: &str) -> Self

Add a package name glob to the include list.

Source

pub fn skip_if_unavailable(self, v: DnfBool) -> Self

Set whether to skip the repository if it is unavailable.

Source

pub fn retries(self, v: Retries) -> Self

Set the number of retries for network operations.

Source

pub fn timeout(self, v: TimeoutSeconds) -> Self

Set the network timeout in seconds.

Source

pub fn max_parallel_downloads(self, v: MaxParallelDownloads) -> Self

Set the maximum number of parallel downloads.

Source

pub fn proxy(self, v: ProxySetting) -> Self

Set the proxy configuration.

Source

pub fn username(self, v: Username) -> Self

Set the username for repository authentication.

Source

pub fn password(self, v: Password) -> Self

Set the password for repository authentication.

Source

pub fn extra(self, key: &str, value: &str) -> Self

Add an extra (unknown) key-value pair to the repository configuration.

Unknown keys are preserved for round-trip fidelity when rendering. If the same key is added multiple times, the values are appended.

Trait Implementations§

Source§

impl Clone for RepoBuilder

Source§

fn clone(&self) -> RepoBuilder

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RepoBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.