works
This commit is contained in:
parent
5baadcf6bb
commit
debaee726f
@ -1,10 +1,11 @@
|
|||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{self, BufRead};
|
use std::io::{self, BufRead};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
use std::fs;
|
||||||
|
use std::error::Error;
|
||||||
|
use serde::Serialize;
|
||||||
use crate::structs::{AptSource, RepoType};
|
use crate::structs::{AptSource, RepoType};
|
||||||
|
|
||||||
/// Loads Debian APT sources from a given file path (e.g., "/etc/apt/sources.list")
|
|
||||||
pub fn load_sources(path: &str) -> io::Result<Vec<AptSource>> {
|
pub fn load_sources(path: &str) -> io::Result<Vec<AptSource>> {
|
||||||
let file = File::open(Path::new(path))?;
|
let file = File::open(Path::new(path))?;
|
||||||
let reader = io::BufReader::new(file);
|
let reader = io::BufReader::new(file);
|
||||||
@ -55,15 +56,7 @@ pub fn load_sources(path: &str) -> io::Result<Vec<AptSource>> {
|
|||||||
Ok(sources)
|
Ok(sources)
|
||||||
}
|
}
|
||||||
|
|
||||||
use std::fs;
|
|
||||||
use std::error::Error;
|
|
||||||
use serde::Serialize;
|
|
||||||
|
|
||||||
/// Save sources into a TOML file with a top-level `repositories` array-of-tables
|
|
||||||
pub fn save_sources_to_toml(sources: &[AptSource], path: &str) -> Result<(), Box<dyn Error>> {
|
pub fn save_sources_to_toml(sources: &[AptSource], path: &str) -> Result<(), Box<dyn Error>> {
|
||||||
// tiny wrapper so toml serializes into:
|
|
||||||
// [[repositories]]
|
|
||||||
// ...
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
struct Repos<'a> {
|
struct Repos<'a> {
|
||||||
repositories: &'a [AptSource],
|
repositories: &'a [AptSource],
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user