Run cargo fmt
This commit is contained in:
parent
2ea91652b7
commit
d083b93f08
@ -2,10 +2,14 @@ use std::io::Write;
|
|||||||
|
|
||||||
use crate::types;
|
use crate::types;
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use ncdufmt::{MajorVersion, MinorVersion, HeaderMetadata, InfoBlock, NcduFile, Directory, FileOrDirectory};
|
use ncdufmt::{
|
||||||
|
Directory, FileOrDirectory, HeaderMetadata, InfoBlock, MajorVersion, MinorVersion, NcduFile,
|
||||||
|
};
|
||||||
|
|
||||||
/// Builds an ncdu file from a stream
|
/// Builds an ncdu file from a stream
|
||||||
pub fn build_ncdu_file(rx: crossbeam::channel::Receiver<types::Entry>/*, _writer: impl Write*/) -> Result<NcduFile> {
|
pub fn build_ncdu_file(
|
||||||
|
rx: crossbeam::channel::Receiver<types::Entry>, /*, _writer: impl Write*/
|
||||||
|
) -> Result<NcduFile> {
|
||||||
let mut ret = NcduFile {
|
let mut ret = NcduFile {
|
||||||
major_version: MajorVersion::default(),
|
major_version: MajorVersion::default(),
|
||||||
minor_version: MinorVersion::default(),
|
minor_version: MinorVersion::default(),
|
||||||
@ -13,20 +17,18 @@ pub fn build_ncdu_file(rx: crossbeam::channel::Receiver<types::Entry>/*, _writer
|
|||||||
contents: Directory {
|
contents: Directory {
|
||||||
info: InfoBlock::new("test-filename.tar".to_string()),
|
info: InfoBlock::new("test-filename.tar".to_string()),
|
||||||
contents: Vec::default(),
|
contents: Vec::default(),
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
while let Ok(entry) = rx.recv() {
|
while let Ok(entry) = rx.recv() {
|
||||||
let mut e = InfoBlock::new(entry.path.to_string_lossy());
|
let mut e = InfoBlock::new(entry.path.to_string_lossy());
|
||||||
e.asize = entry.size;
|
e.asize = entry.size;
|
||||||
ret.contents.contents.push(FileOrDirectory::File(e) );
|
ret.contents.contents.push(FileOrDirectory::File(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(ret)
|
Ok(ret)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
mod collector;
|
||||||
mod tar;
|
mod tar;
|
||||||
mod types;
|
mod types;
|
||||||
mod collector;
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
println!("Hello, world!");
|
println!("Hello, world!");
|
||||||
|
@ -8,10 +8,7 @@ use tar::Archive;
|
|||||||
/// Sends tar entries to a channel
|
/// Sends tar entries to a channel
|
||||||
///
|
///
|
||||||
/// The tar file must be in a decompressed state
|
/// The tar file must be in a decompressed state
|
||||||
pub fn get_entries(
|
pub fn get_entries(tx: crossbeam::channel::Sender<types::Entry>, reader: impl Read) -> Result<()> {
|
||||||
tx: crossbeam::channel::Sender<types::Entry>,
|
|
||||||
reader: impl Read,
|
|
||||||
) -> Result<()> {
|
|
||||||
let mut archive = Archive::new(reader);
|
let mut archive = Archive::new(reader);
|
||||||
|
|
||||||
for entry in archive.entries()? {
|
for entry in archive.entries()? {
|
||||||
|
Loading…
Reference in New Issue
Block a user