feat(tvix/nix-compat): introduce write_worker_trust_level
This is used by the nix client to determine whether or not the daemon trust it. The trust conditions check are daemon-specific, hence not part of nix-compat. Change-Id: Icbcba2f7f1fd58f67e7da72d22a264f5a3f3619d Reviewed-on: https://cl.tvl.fyi/c/depot/+/11231 Reviewed-by: flokli <flokli@flokli.de> Tested-by: BuildkiteCI
This commit is contained in:
parent
017ff431fe
commit
08cc27cc20
1 changed files with 22 additions and 0 deletions
|
@ -81,3 +81,25 @@ pub async fn write_op<W: AsyncWriteExt + Unpin>(w: &mut W, op: &Operation) -> st
|
||||||
))?;
|
))?;
|
||||||
w.write_u64(op).await
|
w.write_u64(op).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
|
pub enum Trust {
|
||||||
|
Trusted,
|
||||||
|
NotTrusted,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Write the worker [Trust] level to the wire.
|
||||||
|
///
|
||||||
|
/// Cpp Nix has a legacy third option: u8 0. This option is meant to
|
||||||
|
/// be used as a backward compatible measure. Since we're not
|
||||||
|
/// targetting protocol versions pre-dating the trust notion, we
|
||||||
|
/// decided not to implement it here.
|
||||||
|
pub async fn write_worker_trust_level<W>(conn: &mut W, t: Trust) -> std::io::Result<()>
|
||||||
|
where
|
||||||
|
W: AsyncReadExt + AsyncWriteExt + Unpin + std::fmt::Debug,
|
||||||
|
{
|
||||||
|
match t {
|
||||||
|
Trust::Trusted => primitive::write_u64(conn, 1).await,
|
||||||
|
Trust::NotTrusted => primitive::write_u64(conn, 2).await,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue