Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
adamnemecek committed Jan 3, 2025
1 parent e57342e commit 0ca980e
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
24 changes: 12 additions & 12 deletions src/archive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,27 @@ pub enum ArchiveMethod {
impl ArchiveMethod {
pub fn extension(self) -> String {
match self {
ArchiveMethod::TarGz => "tar.gz",
ArchiveMethod::Tar => "tar",
ArchiveMethod::Zip => "zip",
Self::TarGz => "tar.gz",
Self::Tar => "tar",
Self::Zip => "zip",
}
.to_string()
}

pub fn content_type(self) -> String {
match self {
ArchiveMethod::TarGz => "application/gzip",
ArchiveMethod::Tar => "application/tar",
ArchiveMethod::Zip => "application/zip",
Self::TarGz => "application/gzip",
Self::Tar => "application/tar",
Self::Zip => "application/zip",
}
.to_string()
}

pub fn is_enabled(self, tar_enabled: bool, tar_gz_enabled: bool, zip_enabled: bool) -> bool {
match self {
ArchiveMethod::TarGz => tar_gz_enabled,
ArchiveMethod::Tar => tar_enabled,
ArchiveMethod::Zip => zip_enabled,
Self::TarGz => tar_gz_enabled,
Self::Tar => tar_enabled,
Self::Zip => zip_enabled,
}
}

Expand All @@ -69,9 +69,9 @@ impl ArchiveMethod {
{
let dir = dir.as_ref();
match self {
ArchiveMethod::TarGz => tar_gz(dir, skip_symlinks, out),
ArchiveMethod::Tar => tar_dir(dir, skip_symlinks, out),
ArchiveMethod::Zip => zip_dir(dir, skip_symlinks, out),
Self::TarGz => tar_gz(dir, skip_symlinks, out),
Self::Tar => tar_dir(dir, skip_symlinks, out),
Self::Zip => zip_dir(dir, skip_symlinks, out),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ impl MiniserveConfig {
.transpose()?
.unwrap_or_default();

Ok(MiniserveConfig {
Ok(Self {
verbose: args.verbose,
path: args.path.unwrap_or_else(|| PathBuf::from(".")),
port,
Expand Down
4 changes: 2 additions & 2 deletions src/listing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ impl Entry {
last_modification_date: Option<SystemTime>,
symlink_info: Option<String>,
) -> Self {
Entry {
Self {
name,
entry_type,
link,
Expand Down Expand Up @@ -153,7 +153,7 @@ pub struct Breadcrumb {

impl Breadcrumb {
fn new(name: String, link: String) -> Self {
Breadcrumb { name, link }
Self { name, link }
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/pipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub struct Pipe {
impl Pipe {
/// Wrap the given sender in a `Pipe`.
pub fn new(destination: Sender<io::Result<Bytes>>) -> Self {
Pipe {
Self {
dest: destination,
bytes: BytesMut::new(),
}
Expand Down
8 changes: 4 additions & 4 deletions src/renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,10 +326,10 @@ pub enum ThemeSlug {
impl ThemeSlug {
pub fn css(&self) -> &str {
match self {
ThemeSlug::Squirrel => grass::include!("data/themes/squirrel.scss"),
ThemeSlug::Archlinux => grass::include!("data/themes/archlinux.scss"),
ThemeSlug::Zenburn => grass::include!("data/themes/zenburn.scss"),
ThemeSlug::Monokai => grass::include!("data/themes/monokai.scss"),
Self::Squirrel => grass::include!("data/themes/squirrel.scss"),
Self::Archlinux => grass::include!("data/themes/archlinux.scss"),
Self::Zenburn => grass::include!("data/themes/zenburn.scss"),
Self::Monokai => grass::include!("data/themes/monokai.scss"),
}
}

Expand Down

0 comments on commit 0ca980e

Please sign in to comment.