Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 8 additions & 15 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,7 @@ impl DisplayBox {
let kl = key.as_ref().len();
let vl = value.as_ref().len();
let total = kl + vl + 6; // two vertical bars, two edge spaces, colon space in centre
let spacing = if total < self.width {
self.width - total
} else {
0
};
let spacing = self.width.saturating_sub(total);
let mut spacer = String::new();
for _ in 0..spacing {
spacer.push(' ');
Expand All @@ -160,7 +156,7 @@ impl DisplayBox {

fn edge(width: usize, top: bool, fg: Color) {
let mut line = String::new();
let hyphens = if width > 2 { width - 2 } else { 0 };
let hyphens = width.saturating_sub(2);
if top {
line.push('/');
} else {
Expand Down Expand Up @@ -271,7 +267,7 @@ impl AvailableArtifactStore {
.log(id)
.map(|x| x.raw())
.flatten_stream()
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e)),
.map_err(std::io::Error::other),
))
}

Expand All @@ -283,13 +279,10 @@ impl AvailableArtifactStore {
self.lava
.job_results_as_junit(id)
.map(|res| match res {
Ok(s) => s
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e))
.boxed(),
Err(e) => futures::stream::once(async move {
Err(std::io::Error::new(std::io::ErrorKind::Other, e))
})
.boxed(),
Ok(s) => s.map_err(std::io::Error::other).boxed(),
Err(e) => {
futures::stream::once(async move { Err(std::io::Error::other(e)) }).boxed()
}
})
.flatten_stream(),
)
Expand Down Expand Up @@ -647,7 +640,7 @@ impl Run {
.job_results_as_junit(id)
.await
.map_err(|_| ())?
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e)),
.map_err(std::io::Error::other),
)
.into_async_read()
.read_to_end(&mut bytes)
Expand Down
8 changes: 4 additions & 4 deletions src/throttled.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,17 +222,17 @@ impl ThrottledLava {
self.inner.tags().await
}

pub async fn devices(&self) -> Throttled<Devices> {
pub async fn devices(&self) -> Throttled<'_, Devices<'_>> {
let permit = self.throttler.acquire("devices").await;
Throttled::new(self.inner.devices(), permit)
}

pub async fn log(&self, id: i64) -> ThrottledJobLogBuilder {
pub async fn log(&self, id: i64) -> ThrottledJobLogBuilder<'_> {
let permit = self.throttler.acquire("log").await;
ThrottledJobLogBuilder::new(self.inner.log(id), permit)
}

pub async fn jobs(&self) -> ThrottledJobsBuilder {
pub async fn jobs(&self) -> ThrottledJobsBuilder<'_> {
let permit = self.throttler.acquire("jobs").await;
ThrottledJobsBuilder::new(self.inner.jobs(), permit)
}
Expand All @@ -255,7 +255,7 @@ impl ThrottledLava {
job::job_results_as_junit(&self.inner, id).await
}

pub async fn workers(&self) -> Throttled<Paginator<Worker>> {
pub async fn workers(&self) -> Throttled<'_, Paginator<Worker>> {
let permit = self.throttler.acquire("workers").await;
Throttled::new(self.inner.workers(), permit)
}
Expand Down