refactor(tvix/nix-compat/wire): simplify write_bytes a bit
Use the same EMPTY_BYTES trick from BytesWriter to write out the padding, rather than allocating a Vec. Change-Id: Ifb4ba1b45b7388adbc135fc8e46fd3d3cedd30aa Reviewed-on: https://cl.tvl.fyi/c/depot/+/11375 Reviewed-by: picnoir picnoir <picnoir@alternativebit.fr> Autosubmit: flokli <flokli@flokli.de> Tested-by: BuildkiteCI
This commit is contained in:
parent
eb910dfa3a
commit
acee489866
2 changed files with 14 additions and 10 deletions
|
|
@ -3,12 +3,11 @@ use std::task::{ready, Poll};
|
|||
|
||||
use tokio::io::AsyncWrite;
|
||||
|
||||
use super::bytes::EMPTY_BYTES;
|
||||
|
||||
/// The length of the size field, in bytes is always 8.
|
||||
const LEN_SIZE: usize = 8;
|
||||
|
||||
/// 8 null bytes, used to write out padding.
|
||||
const EMPTY_BYTES: &[u8; 8] = &[0u8; 8];
|
||||
|
||||
pin_project! {
|
||||
/// Writes a "bytes wire packet" to the underlying writer.
|
||||
/// The format is the same as in [crate::wire::bytes::write_bytes],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue