mirror of
https://github.com/htrefil/rkvm.git
synced 2025-01-30 20:34:13 +01:00
Trace message sizes
This commit is contained in:
parent
046c5e71ba
commit
0da5dc759f
3 changed files with 10 additions and 2 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -806,6 +806,7 @@ dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"bincode",
|
"bincode",
|
||||||
"hmac",
|
"hmac",
|
||||||
|
"log",
|
||||||
"rand",
|
"rand",
|
||||||
"rkvm-input",
|
"rkvm-input",
|
||||||
"serde",
|
"serde",
|
||||||
|
|
|
@ -16,3 +16,4 @@ thiserror = "1.0.40"
|
||||||
hmac = "0.12.1"
|
hmac = "0.12.1"
|
||||||
sha2 = "0.10.6"
|
sha2 = "0.10.6"
|
||||||
rand = "0.8.5"
|
rand = "0.8.5"
|
||||||
|
log = "0.4.11"
|
|
@ -19,9 +19,13 @@ impl<T: DeserializeOwned + Serialize + Sync> Message for T {
|
||||||
let mut data = vec![0; length.into()];
|
let mut data = vec![0; length.into()];
|
||||||
stream.read_exact(&mut data).await?;
|
stream.read_exact(&mut data).await?;
|
||||||
|
|
||||||
options()
|
let data = options()
|
||||||
.deserialize(&data)
|
.deserialize(&data)
|
||||||
.map_err(|err| Error::new(ErrorKind::InvalidData, err))
|
.map_err(|err| Error::new(ErrorKind::InvalidData, err))?;
|
||||||
|
|
||||||
|
log::trace!("Read {} bytes", 2 + length);
|
||||||
|
|
||||||
|
Ok(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn encode<W: AsyncWrite + Send + Unpin>(&self, stream: &mut W) -> Result<(), Error> {
|
async fn encode<W: AsyncWrite + Send + Unpin>(&self, stream: &mut W) -> Result<(), Error> {
|
||||||
|
@ -37,6 +41,8 @@ impl<T: DeserializeOwned + Serialize + Sync> Message for T {
|
||||||
stream.write_u16(length).await?;
|
stream.write_u16(length).await?;
|
||||||
stream.write_all(&data).await?;
|
stream.write_all(&data).await?;
|
||||||
|
|
||||||
|
log::trace!("Wrote {} bytes", 2 + data.len());
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue