Loading crates/s3s/Cargo.toml +1 −1 Original line number Diff line number Diff line Loading @@ -15,7 +15,6 @@ rustdoc-args = ["--cfg", "docsrs"] [dependencies] arrayvec = "0.7.2" ascii = { version = "1.1.0", default-features = false } async-trait = "0.1.68" atoi = { version = "2.0.0", default-features = false } base64-simd = "0.8.0" Loading @@ -32,6 +31,7 @@ hyper = { version = "0.14.26", features = ["stream"] } memchr = "2.5.0" mime = "0.3.17" nom = "7.1.3" nugine-rust-utils = { version = "0.1.2", features = ["ascii", "utf8"] } pin-project-lite = "0.2.9" quick-xml = { version = "0.28.2", features = ["serialize"] } serde = { version = "1.0.160", features = ["derive"] } Loading crates/s3s/src/dto/range.rs +2 −2 Original line number Diff line number Diff line //! HTTP Range header use crate::http; use crate::utils::from_ascii; use crate::S3Error; use crate::S3ErrorCode; use std::ops; use atoi::FromRadix10Checked; use rust_utils::str_from_ascii; /// HTTP Range header /// Loading Loading @@ -145,7 +145,7 @@ impl http::TryFromHeaderValue for Range { type Error = ParseRangeError; fn try_from_header_value(val: &http::HeaderValue) -> Result<Self, Self::Error> { let header = from_ascii(val.as_bytes()).ok_or(ParseRangeError { _priv: () })?; let header = str_from_ascii(val.as_bytes()).ok_or(ParseRangeError { _priv: () })?; Self::parse(header) } } Loading crates/s3s/src/http/de.rs +2 −2 Original line number Diff line number Diff line Loading @@ -4,12 +4,12 @@ use crate::dto::{List, Metadata, StreamingBlob, Timestamp, TimestampFormat}; use crate::error::*; use crate::http::{HeaderName, HeaderValue}; use crate::path::S3Path; use crate::utils::from_utf8_vec; use crate::xml; use std::fmt; use std::str::FromStr; use rust_utils::string_from_utf8; use tracing::debug; fn missing_header(name: &HeaderName) -> S3Error { Loading Loading @@ -188,7 +188,7 @@ where pub fn take_string_body(req: &mut Request) -> S3Result<String> { let bytes = req.body.bytes().expect("full body not found"); match from_utf8_vec(bytes.into()) { match string_from_utf8(bytes.into()) { Some(s) => Ok(s), None => Err(invalid_request!("expected UTF-8 body")), } Loading crates/s3s/src/sig_v4/methods.rs +2 −2 Original line number Diff line number Diff line Loading @@ -4,7 +4,6 @@ use super::AmzDate; use crate::auth::SecretKey; use crate::http::OrderedHeaders; use crate::utils::from_ascii; use crate::utils::hmac_sha256; use crate::utils::stable_sort_by_first; Loading @@ -13,6 +12,7 @@ use std::mem::MaybeUninit; use hex_simd::{AsOut, AsciiCase}; use hyper::body::Bytes; use hyper::Method; use rust_utils::str_from_ascii; use sha2::{Digest, Sha256}; use smallvec::SmallVec; use zeroize::Zeroize; Loading Loading @@ -75,7 +75,7 @@ fn uri_encode(output: &mut String, input: &str, encode_slash: bool) { } } let s = from_ascii(buf.as_ref()).unwrap(); let s = str_from_ascii(buf.as_ref()).unwrap(); output.push_str(s); } Loading crates/s3s/src/utils.rs +0 −11 Original line number Diff line number Diff line Loading @@ -6,17 +6,6 @@ use std::pin::Pin; use arrayvec::{ArrayString, ArrayVec}; /// TODO(blocking): use `unicode_simd::from_ascii` pub fn from_ascii(s: &[u8]) -> Option<&str> { ascii::AsciiStr::from_ascii(s).ok().map(ascii::AsciiStr::as_str) } /// TODO(blocking): SIMD /// `https://github.com/rusticstuff/simdutf8/issues/73` pub fn from_utf8_vec(v: Vec<u8>) -> Option<String> { String::from_utf8(v).ok() } /// on-stack formatting pub const fn fmt_boolean(val: bool) -> &'static str { if val { Loading Loading
crates/s3s/Cargo.toml +1 −1 Original line number Diff line number Diff line Loading @@ -15,7 +15,6 @@ rustdoc-args = ["--cfg", "docsrs"] [dependencies] arrayvec = "0.7.2" ascii = { version = "1.1.0", default-features = false } async-trait = "0.1.68" atoi = { version = "2.0.0", default-features = false } base64-simd = "0.8.0" Loading @@ -32,6 +31,7 @@ hyper = { version = "0.14.26", features = ["stream"] } memchr = "2.5.0" mime = "0.3.17" nom = "7.1.3" nugine-rust-utils = { version = "0.1.2", features = ["ascii", "utf8"] } pin-project-lite = "0.2.9" quick-xml = { version = "0.28.2", features = ["serialize"] } serde = { version = "1.0.160", features = ["derive"] } Loading
crates/s3s/src/dto/range.rs +2 −2 Original line number Diff line number Diff line //! HTTP Range header use crate::http; use crate::utils::from_ascii; use crate::S3Error; use crate::S3ErrorCode; use std::ops; use atoi::FromRadix10Checked; use rust_utils::str_from_ascii; /// HTTP Range header /// Loading Loading @@ -145,7 +145,7 @@ impl http::TryFromHeaderValue for Range { type Error = ParseRangeError; fn try_from_header_value(val: &http::HeaderValue) -> Result<Self, Self::Error> { let header = from_ascii(val.as_bytes()).ok_or(ParseRangeError { _priv: () })?; let header = str_from_ascii(val.as_bytes()).ok_or(ParseRangeError { _priv: () })?; Self::parse(header) } } Loading
crates/s3s/src/http/de.rs +2 −2 Original line number Diff line number Diff line Loading @@ -4,12 +4,12 @@ use crate::dto::{List, Metadata, StreamingBlob, Timestamp, TimestampFormat}; use crate::error::*; use crate::http::{HeaderName, HeaderValue}; use crate::path::S3Path; use crate::utils::from_utf8_vec; use crate::xml; use std::fmt; use std::str::FromStr; use rust_utils::string_from_utf8; use tracing::debug; fn missing_header(name: &HeaderName) -> S3Error { Loading Loading @@ -188,7 +188,7 @@ where pub fn take_string_body(req: &mut Request) -> S3Result<String> { let bytes = req.body.bytes().expect("full body not found"); match from_utf8_vec(bytes.into()) { match string_from_utf8(bytes.into()) { Some(s) => Ok(s), None => Err(invalid_request!("expected UTF-8 body")), } Loading
crates/s3s/src/sig_v4/methods.rs +2 −2 Original line number Diff line number Diff line Loading @@ -4,7 +4,6 @@ use super::AmzDate; use crate::auth::SecretKey; use crate::http::OrderedHeaders; use crate::utils::from_ascii; use crate::utils::hmac_sha256; use crate::utils::stable_sort_by_first; Loading @@ -13,6 +12,7 @@ use std::mem::MaybeUninit; use hex_simd::{AsOut, AsciiCase}; use hyper::body::Bytes; use hyper::Method; use rust_utils::str_from_ascii; use sha2::{Digest, Sha256}; use smallvec::SmallVec; use zeroize::Zeroize; Loading Loading @@ -75,7 +75,7 @@ fn uri_encode(output: &mut String, input: &str, encode_slash: bool) { } } let s = from_ascii(buf.as_ref()).unwrap(); let s = str_from_ascii(buf.as_ref()).unwrap(); output.push_str(s); } Loading
crates/s3s/src/utils.rs +0 −11 Original line number Diff line number Diff line Loading @@ -6,17 +6,6 @@ use std::pin::Pin; use arrayvec::{ArrayString, ArrayVec}; /// TODO(blocking): use `unicode_simd::from_ascii` pub fn from_ascii(s: &[u8]) -> Option<&str> { ascii::AsciiStr::from_ascii(s).ok().map(ascii::AsciiStr::as_str) } /// TODO(blocking): SIMD /// `https://github.com/rusticstuff/simdutf8/issues/73` pub fn from_utf8_vec(v: Vec<u8>) -> Option<String> { String::from_utf8(v).ok() } /// on-stack formatting pub const fn fmt_boolean(val: bool) -> &'static str { if val { Loading