This commit is contained in:
shibazaki 2025-10-05 20:13:02 +02:00
parent 5baadcf6bb
commit debaee726f

View File

@ -1,10 +1,11 @@
use std::fs::File;
use std::io::{self, BufRead};
use std::path::Path;
use std::fs;
use std::error::Error;
use serde::Serialize;
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>> {
let file = File::open(Path::new(path))?;
let reader = io::BufReader::new(file);
@ -55,15 +56,7 @@ pub fn load_sources(path: &str) -> io::Result<Vec<AptSource>> {
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>> {
// tiny wrapper so toml serializes into:
// [[repositories]]
// ...
#[derive(Serialize)]
struct Repos<'a> {
repositories: &'a [AptSource],