use crate::magic::NBD_REPLY_MAGIC;
pub(crate) struct OptionReplyRaw {
option: u32,
reply_type: u32,
data: Vec<u8>,
}
impl OptionReplyRaw {
pub(crate) fn new(option: u32, reply_type: u32, data: Vec<u8>) -> Self {
Self {
option,
reply_type,
data,
}
}
pub(crate) async fn write<W>(&self, writer: &mut W) -> Result<(), std::io::Error>
where
W: tokio::io::AsyncWriteExt + Unpin,
{
writer.write_u64(NBD_REPLY_MAGIC).await?;
writer.write_u32(self.option).await?;
writer.write_u32(self.reply_type).await?;
writer.write_u32(self.data.len() as u32).await?;
writer.write_all(&self.data).await?;
Ok(())
}
}