fix(tvix/nix-compat): Feature flag code only used in async

When only the wire feature was enabled two methods were unused and so
would faild `cargo check --no-default-features --features wire`.

This feature flags those two methods on async feature since that is the
only place they are used.

Change-Id: I6ec18a670e3c6e3ecee8d1417c99f1a5084e0ae7
Reviewed-on: https://cl.tvl.fyi/c/depot/+/12346
Reviewed-by: flokli <flokli@flokli.de>
Autosubmit: Brian Olsen <me@griff.name>
Tested-by: BuildkiteCI
This commit is contained in:
Brian Olsen 2024-08-25 13:15:22 +02:00 committed by clbot
parent ced05a2bb6
commit 228bf55646

View file

@ -1,9 +1,12 @@
#[cfg(feature = "async")]
use std::mem::MaybeUninit;
use std::{
io::{Error, ErrorKind},
mem::MaybeUninit,
ops::RangeInclusive,
};
use tokio::io::{self, AsyncReadExt, AsyncWriteExt, ReadBuf};
#[cfg(feature = "async")]
use tokio::io::ReadBuf;
use tokio::io::{self, AsyncReadExt, AsyncWriteExt};
pub(crate) mod reader;
pub use reader::BytesReader;
@ -79,6 +82,7 @@ where
Ok(buf)
}
#[cfg(feature = "async")]
pub(crate) async fn read_bytes_buf<'a, const N: usize, R>(
reader: &mut R,
buf: &'a mut [MaybeUninit<u8>; N],
@ -132,6 +136,7 @@ where
}
/// SAFETY: The bytes have to actually be initialized.
#[cfg(feature = "async")]
unsafe fn assume_init_bytes(slice: &[MaybeUninit<u8>]) -> &[u8] {
&*(slice as *const [MaybeUninit<u8>] as *const [u8])
}