refactor(nix-compat/wire): drop primitive functions

These may as well be inlined, and hardly need tests, since they just
alias AsyncReadExt::read_u64_le / AsyncWriteExt::write_u64_le.

Boolean reading is worth making explicit, since callers may differ on
how they want to handle values other than 0 and 1.

Boolean writing simplifies to `.write_u64_le(x as u64)`, which is also
fine to inline.

Change-Id: Ief9722fe886688693feb924ff0306b5bc68dd7a2
Reviewed-on: https://cl.tvl.fyi/c/depot/+/11549
Reviewed-by: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
This commit is contained in:
edef 2024-04-30 07:15:37 +00:00
parent b3305ea6e2
commit 095f715a80
6 changed files with 33 additions and 112 deletions

View file

@ -4,7 +4,7 @@ use tokio_listener::{self, SystemOptions, UserOptions};
use tracing::{debug, error, info, instrument, Level};
use nix_compat::worker_protocol::{self, server_handshake_client, ClientSettings, Trust};
use nix_compat::{wire, ProtocolVersion};
use nix_compat::ProtocolVersion;
#[derive(Parser, Debug)]
struct Cli {
@ -78,7 +78,9 @@ where
// TODO: implement logging. For now, we'll just send
// STDERR_LAST, which is good enough to get Nix respond to
// us.
wire::write_u64(&mut client_connection.conn, worker_protocol::STDERR_LAST)
client_connection
.conn
.write_u64_le(worker_protocol::STDERR_LAST)
.await
.unwrap();
loop {
@ -109,6 +111,6 @@ where
let settings = worker_protocol::read_client_settings(&mut conn.conn, conn.version).await?;
// The client expects us to send some logs when we're processing
// the settings. Sending STDERR_LAST signal we're done processing.
wire::write_u64(&mut conn.conn, worker_protocol::STDERR_LAST).await?;
conn.conn.write_u64_le(worker_protocol::STDERR_LAST).await?;
Ok(settings)
}