clippy: fix result_unit_err warnings (#31791)

* clippy: fix `result_unit_err` warnings

* feat: fix result warnings in script

* doc: document `generate_key` return type

Co-authored-by: Martin Robinson <mrobinson@igalia.com>

* feat: add back result to RangeRequestBounds::get_final

Co-authored-by: Martin Robinson <mrobinson@igalia.com>

---------

Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
eri 2024-03-21 13:51:45 +01:00 committed by GitHub
parent ea62a5e24f
commit da696b7e57
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 175 additions and 191 deletions

View file

@ -569,7 +569,7 @@ pub enum RangeRequestBounds {
}
impl RangeRequestBounds {
pub fn get_final(&self, len: Option<u64>) -> Result<RelativePos, ()> {
pub fn get_final(&self, len: Option<u64>) -> Result<RelativePos, &'static str> {
match self {
RangeRequestBounds::Final(pos) => {
if let Some(len) = len {
@ -577,7 +577,7 @@ impl RangeRequestBounds {
return Ok(pos.clone());
}
}
Err(())
Err("Tried to process RangeRequestBounds::Final without len")
},
RangeRequestBounds::Pending(offset) => Ok(RelativePos::from_opts(
if let Some(len) = len {
@ -750,12 +750,10 @@ async fn scheme_fetch(
let range_header = request.headers.typed_get::<Range>();
let is_range_request = range_header.is_some();
let range = match get_range_request_bounds(range_header).get_final(file_size) {
Ok(range) => range,
Err(_) => {
range_not_satisfiable_error(&mut response);
return response;
},
let Ok(range) = get_range_request_bounds(range_header).get_final(file_size)
else {
range_not_satisfiable_error(&mut response);
return response;
};
let mut reader = BufReader::with_capacity(FILE_CHUNK_SIZE, file);
if reader.seek(SeekFrom::Start(range.start as u64)).is_err() {