Struct SourcesManager

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

Manager for APT sources and keyrings

Implementations§

Source§

impl SourcesManager

Source

pub fn new( sources_dir: impl Into<PathBuf>, keyring_dir: impl Into<PathBuf>, ) -> Self

Create a new SourcesManager with custom directories

Source

pub fn sources_dir(&self) -> &Path

Get the path to the sources directory

Source

pub fn keyring_dir(&self) -> &Path

Get the path to the keyring directory

Source

pub fn generate_filename(&self, name: &str, format: FileFormat) -> String

Generate a filename for a repository

Source

pub fn get_repository_path(&self, filename: &str) -> PathBuf

Get the full path for a repository file

Source

pub fn get_keyring_path(&self, filename: &str) -> PathBuf

Get the full path for a keyring file

Source

pub fn write_repositories( &self, path: &Path, repositories: &Repositories, ) -> Result<()>

Write repositories to a file

Source

pub fn read_repositories(&self, path: &Path) -> Result<Repositories, String>

Read repositories from a file

Source

pub fn list_repository_files(&self) -> Result<Vec<PathBuf>>

List all repository files in the sources directory

Source

pub fn scan_all_repositories( &self, ) -> Result<Vec<(PathBuf, Repositories)>, String>

Scan all repository files and return their contents

Source

pub fn repository_exists( &self, repository: &Repository, ) -> Result<Option<PathBuf>, String>

Check if a repository already exists in any file

Source

pub fn ensure_directories(&self) -> Result<()>

Ensure the sources and keyring directories exist

Source

pub fn add_repository( &self, repository: &Repository, filename: &str, ) -> Result<(), String>

Add a repository to a file, creating the file if it doesn’t exist

Source

pub fn remove_repository(&self, repository: &Repository) -> Result<bool, String>

Remove a repository from all files

Source

pub fn set_repository_enabled( &self, repository: &Repository, enabled: bool, ) -> Result<bool, String>

Enable or disable a repository

Source

pub fn add_component_to_repositories( &self, component: &str, filter: impl Fn(&Repository) -> bool, ) -> Result<u32, String>

Add a component to all matching repositories

Source

pub fn enable_source_repositories( &self, create_if_missing: bool, ) -> Result<(u32, u32), String>

Enable source repositories

Source

pub fn list_all_repositories( &self, ) -> Result<Vec<(PathBuf, Repository)>, String>

List all repositories with their file paths

Source

pub fn generate_keyring_filename(&self, repository_name: &str) -> String

Generate a keyring filename for a repository

Source

pub fn save_key(&self, key_data: &[u8], filename: &str) -> Result<PathBuf>

Save a GPG key to the keyring directory

Trait Implementations§

Source§

impl Clone for SourcesManager

Source§

fn clone(&self) -> SourcesManager

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for SourcesManager

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for SourcesManager

Source§

fn default() -> Self

Returns the “default value” for a type. 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.
Source§

impl<T> ErasedDestructor for T
where T: 'static,