clawhdf5-remote: clippy clean with every feature set
checked_div in the test server's throttle, a slice for the single range of fetch_first, and dead-code allowances for the redaction helpers in a build with neither http nor a cloud store. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
@@ -66,12 +66,20 @@ pub fn redact_url(url: &str) -> String {
|
|||||||
/// Replaces the secret parts of one URL (its userinfo and query string,
|
/// Replaces the secret parts of one URL (its userinfo and query string,
|
||||||
/// and the URL itself) wherever they appear in a message — such as the
|
/// and the URL itself) wherever they appear in a message — such as the
|
||||||
/// text of an error from the HTTP client.
|
/// text of an error from the HTTP client.
|
||||||
|
#[cfg_attr(
|
||||||
|
not(any(feature = "http", feature = "s3", feature = "gcs", feature = "azure")),
|
||||||
|
allow(dead_code)
|
||||||
|
)]
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub(crate) struct Redactor {
|
pub(crate) struct Redactor {
|
||||||
shown: String,
|
shown: String,
|
||||||
secrets: Vec<(String, String)>,
|
secrets: Vec<(String, String)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(
|
||||||
|
not(any(feature = "http", feature = "s3", feature = "gcs", feature = "azure")),
|
||||||
|
allow(dead_code)
|
||||||
|
)]
|
||||||
impl Redactor {
|
impl Redactor {
|
||||||
pub(crate) fn new(url: &str) -> Redactor {
|
pub(crate) fn new(url: &str) -> Redactor {
|
||||||
let shown = redact_url(url);
|
let shown = redact_url(url);
|
||||||
@@ -177,7 +185,10 @@ pub enum RemoteError {
|
|||||||
|
|
||||||
impl RemoteError {
|
impl RemoteError {
|
||||||
/// The error with every secret part of `r`'s URL scrubbed from its text.
|
/// The error with every secret part of `r`'s URL scrubbed from its text.
|
||||||
#[cfg_attr(not(any(feature = "http", feature = "object-store")), allow(dead_code))]
|
#[cfg_attr(
|
||||||
|
not(any(feature = "http", feature = "s3", feature = "gcs", feature = "azure")),
|
||||||
|
allow(dead_code)
|
||||||
|
)]
|
||||||
pub(crate) fn scrubbed(self, r: &Redactor) -> RemoteError {
|
pub(crate) fn scrubbed(self, r: &Redactor) -> RemoteError {
|
||||||
let f = |s: String| r.scrub(&s);
|
let f = |s: String| r.scrub(&s);
|
||||||
match self {
|
match self {
|
||||||
|
|||||||
@@ -140,7 +140,10 @@ impl ObjectStoreStorage {
|
|||||||
|
|
||||||
/// The object's first `n` bytes (fewer if it is shorter).
|
/// The object's first `n` bytes (fewer if it is shorter).
|
||||||
pub(crate) fn fetch_first(&self, n: u64) -> Result<Vec<u8>, RemoteError> {
|
pub(crate) fn fetch_first(&self, n: u64) -> Result<Vec<u8>, RemoteError> {
|
||||||
Ok(self.fetch_all(&[0..n])?.pop().unwrap_or_default())
|
Ok(self
|
||||||
|
.fetch_all(std::slice::from_ref(&(0..n)))?
|
||||||
|
.pop()
|
||||||
|
.unwrap_or_default())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fetch_all(&self, ranges: &[Range<u64>]) -> Result<Vec<Vec<u8>>, RemoteError> {
|
fn fetch_all(&self, ranges: &[Range<u64>]) -> Result<Vec<Vec<u8>>, RemoteError> {
|
||||||
|
|||||||
@@ -405,8 +405,8 @@ fn serve(conn: TcpStream, s: &Shared) -> std::io::Result<()> {
|
|||||||
for piece in rest.chunks(4096) {
|
for piece in rest.chunks(4096) {
|
||||||
out.write_all(piece)?;
|
out.write_all(piece)?;
|
||||||
out.flush()?;
|
out.flush()?;
|
||||||
if bps > 0 {
|
if let Some(us) = (4096 * 1_000_000u64).checked_div(bps) {
|
||||||
std::thread::sleep(Duration::from_micros(4096 * 1_000_000 / bps));
|
std::thread::sleep(Duration::from_micros(us));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user