diff options
| author | aur-build <aur-build@localhost> | 2026-11-22 10:36:24 +0000 |
|---|---|---|
| committer | aur-build <aur-build@localhost> | 2026-11-22 10:36:24 +0000 |
| commit | 3dc71b2f5160ef9bd46143eed0edb5d2557b58e6 (patch) | |
| tree | 7cc7169181b4bdd73fd8817f8c1d7cce6e6998a8 /src/sandbox/remote.rs | |
| parent | 9dc9087d89891c6e5ef7e5dc084dd13c8611843e (diff) | |
| download | aur-build-3dc71b2f5160ef9bd46143eed0edb5d2557b58e6.tar.gz aur-build-3dc71b2f5160ef9bd46143eed0edb5d2557b58e6.zip | |
rustfmt,lints: pin the formatting, adopt the idiom lints, pay them off
rustfmt.toml fixes the shape the tree is written in (120 columns, small
items kept on one line) and one canonical pass makes it the truth.
[lints.clippy] names the idiom lints worth enforcing and leaves out the
two that would add doc-comment boilerplate rather than remove it. The
tree pays them off here: write!/writeln! instead of push_str(&format!()),
let-else instead of match-on-Option, borrows where a thread entry point
only reads what it owns, no `&self` on a Copy state and no `self` nobody
reads.
ops::to_prometheus gains one gauge helper: a metric's HELP, TYPE and
value are now emitted by the same call instead of three.
Diffstat (limited to 'src/sandbox/remote.rs')
| -rw-r--r-- | src/sandbox/remote.rs | 41 |
1 files changed, 17 insertions, 24 deletions
diff --git a/src/sandbox/remote.rs b/src/sandbox/remote.rs index 8366e97..f881eb0 100644 --- a/src/sandbox/remote.rs +++ b/src/sandbox/remote.rs @@ -14,7 +14,7 @@ use crate::sandbox::{Exit, Sandbox, SandboxBackend, SandboxInfo, SandboxSpec}; /// only way to reach it, and the alias is what carries the /// feature-conditional visibility. mod remote_backend { - use super::*; + use super::{Config, Receiver}; // `pub` fields inside a private module are not nameable from // outside; they stay readable by the impls below. @@ -61,20 +61,16 @@ impl RemoteBackend { impl SandboxBackend for RemoteBackend { fn acquire(&self, spec: &SandboxSpec) -> Result<Arc<dyn Sandbox>> { - let stream = self.queue.recv_timeout(spec.ttl).map_err(|_| { - Error::other(format!( - "no sandbox connected to {} within the lease window", - self.addr - )) - })?; + let stream = self + .queue + .recv_timeout(spec.ttl) + .map_err(|_| Error::other(format!("no sandbox connected to {} within the lease window", self.addr)))?; let _ = stream.set_read_timeout(Some(spec.ttl)); let mut reader = BufReader::new(stream.try_clone()?); let agent_id = match wire::read_frame(&mut reader)? { Some(Frame::Hello { token, agent_id, profiles }) => { if token != self.token { - return Err(Error::fail_closed(format!( - "sandbox {agent_id} presented the wrong token" - ))); + return Err(Error::fail_closed(format!("sandbox {agent_id} presented the wrong token"))); } if !profiles.is_empty() && !profiles.contains(&spec.profile) { return Err(Error::fail_closed(format!( @@ -89,16 +85,11 @@ impl SandboxBackend for RemoteBackend { }; wire::write_frame(&mut stream.try_clone()?, &Frame::HelloAck { ttl_secs: spec.ttl.as_secs().max(1) })?; let _ = stream.set_read_timeout(None); - Ok(Arc::new(RemoteSandbox::after_hello( - &self.cfg, stream, agent_id, spec.ttl, - ))) + Ok(Arc::new(RemoteSandbox::after_hello(&self.cfg, stream, agent_id, spec.ttl))) } fn status(&self) -> Result<Vec<SandboxInfo>> { - Ok(vec![SandboxInfo { - id: format!("remote@{}", self.addr), - profile: self.cfg.build_profile.clone(), - }]) + Ok(vec![SandboxInfo { id: format!("remote@{}", self.addr), profile: self.cfg.build_profile.clone() }]) } } @@ -112,10 +103,13 @@ pub(crate) struct RemoteSandbox { } impl RemoteSandbox { - pub(crate) fn after_hello(cfg: &Config, stream: std::net::TcpStream, agent_id: String, ttl: std::time::Duration) -> Self { - let reader = BufReader::new( - stream.try_clone().expect("cloning a connected tcp stream cannot fail"), - ); + pub(crate) fn after_hello( + cfg: &Config, + stream: std::net::TcpStream, + agent_id: String, + ttl: std::time::Duration, + ) -> Self { + let reader = BufReader::new(stream.try_clone().expect("cloning a connected tcp stream cannot fail")); Self { cfg: cfg.clone(), id: agent_id, @@ -132,9 +126,8 @@ impl RemoteSandbox { fn pump(&self, req: u64, sink: &mut dyn FnMut(&str, &[u8])) -> Result<Frame> { loop { - let frame = match wire::read_frame(&mut *self.reader.lock().unwrap())? { - Some(f) => f, - None => return Err(Error::other(format!("sandbox {} vanished", self.id))), + let Some(frame) = wire::read_frame(&mut *self.reader.lock().unwrap())? else { + return Err(Error::other(format!("sandbox {} vanished", self.id))); }; match frame { Frame::Log { req: r, ref stream, ref data } if r == req => { |
