diff --git a/README.md b/README.md index 1f7e322..ba0781f 100644 --- a/README.md +++ b/README.md @@ -151,7 +151,8 @@ run-time behavior: until wastebin responds with 408, by default it is set to 5 seconds. * `WASTEBIN_MAX_BODY_SIZE` number of bytes to accept for POST requests. Defaults to 1 MB. -* `WASTEBIN_MAX_PASTE_EXPIRATION` maximum allowed lifetime of a paste in seconds. Leave empty or set to -1 for no limit. Defaults to no limit. +* `WASTEBIN_MAX_PASTE_EXPIRATION` maximum allowed lifetime of a paste in + seconds. Defaults to unlimited. * `WASTEBIN_PASSWORD_SALT` salt used to hash user passwords used for encrypting pastes. * `WASTEBIN_SIGNING_KEY` sets the key to sign cookies. If not set, a random key diff --git a/src/env.rs b/src/env.rs index cd6bc68..96f6047 100644 --- a/src/env.rs +++ b/src/env.rs @@ -47,11 +47,6 @@ pub enum Error { HttpTimeout(ParseIntError), #[error("failed to parse {VAR_MAX_PASTE_EXPIRATION}: {0}")] MaxPasteExpiration(ParseIntError), - #[error( - "{VAR_MAX_PASTE_EXPIRATION} is too large (max {}), pass -1 if you mean no expiry", - u32::MAX - )] - ExpirationTooLarge, } pub struct BasePath(String); @@ -186,15 +181,6 @@ pub fn http_timeout() -> Result { pub fn max_paste_expiration() -> Result, Error> { std::env::var(VAR_MAX_PASTE_EXPIRATION) .ok() - .and_then(|raw_max_exp| -> Option> { - match raw_max_exp.parse::() { - Ok(-1) => None, - Ok(max_exp) if max_exp >= i64::from(u32::MAX) => { - Some(Err(Error::ExpirationTooLarge)) - } - Ok(max_exp) => Some(Ok(u32::try_from(max_exp).expect("fitting value"))), - Err(why) => Some(Err(Error::MaxPasteExpiration(why))), - } - }) + .map(|value| value.parse::().map_err(Error::MaxPasteExpiration)) .transpose() }