minor refactoring

- `use crate::` where appropriate
- cleanup CLI parsing
- `Uri::with_protocol` -> `Uri::new`
This commit is contained in:
Jörn-Michael Miehe 2025-06-18 13:04:04 +00:00
parent 6ca3e6c9dd
commit de07d556a2
5 changed files with 11 additions and 8 deletions

View file

@ -55,6 +55,7 @@
- client error rework
- current variants are too "low level"
- use variants like `InvalidEndpoint`, `InvalidAlias` etc.
- `Uploading::abort() -> Checked`
- hashing
- store file hashes with all `file::*` variants

View file

@ -8,7 +8,7 @@ use console::style;
use indicatif::{ProgressBar, ProgressStyle};
use log::{debug, warn};
use super::{
use crate::{
cachefile::CacheFile,
cli::Cli,
file::{self, Chunk, FileTrait},

View file

@ -8,7 +8,7 @@ use std::{
use log::trace;
use serde::{Deserialize, Serialize};
use super::{
use crate::{
cli::Cli,
file::{self, FileTrait},
sharry::{self, Client, Uri},

View file

@ -1,6 +1,8 @@
use std::{
convert::Infallible,
fmt,
hash::{DefaultHasher, Hash, Hasher},
io,
time::Duration,
};
@ -10,7 +12,7 @@ use clap::{
value_parser,
};
use super::{
use crate::{
file::Checked,
sharry::{NewShareRequest, Uri},
};
@ -79,12 +81,12 @@ impl fmt::Debug for Cli {
}
}
fn parse_seconds(data: &str) -> Result<Duration, String> {
fn parse_seconds(data: &str) -> Result<Duration, Infallible> {
data.parse().or(Ok(0)).map(Duration::from_secs)
}
fn parse_sharry_file(data: &str) -> Result<Checked, String> {
Checked::new(data).map_err(|e| e.to_string())
fn parse_sharry_file(data: &str) -> io::Result<Checked> {
Checked::new(data)
}
impl Cli {
@ -93,7 +95,7 @@ impl Cli {
}
pub fn get_uri(&self) -> Uri {
Uri::with_protocol(&self.protocol, &self.url)
Uri::new(&self.protocol, &self.url)
}
pub fn get_share_request(&self) -> NewShareRequest {

View file

@ -10,7 +10,7 @@ pub struct Uri {
}
impl Uri {
pub fn with_protocol(protocol: impl Into<String>, base_url: impl Into<String>) -> Self {
pub fn new(protocol: impl Into<String>, base_url: impl Into<String>) -> Self {
Self {
protocol: protocol.into(),
base_url: base_url.into(),