diff options
author | Alex Auvolat <alex@adnab.me> | 2022-07-21 19:05:51 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2022-07-21 19:05:51 +0200 |
commit | 44bbc1c00c2532e08dff0d4a547b0a707e89f32d (patch) | |
tree | a6c021ae50370b3c065e3485ef1dd06052a962c9 /src/util.rs | |
parent | 26989bba1409bfc093e58ef98e75885b10ad7c1c (diff) | |
download | netapp-44bbc1c00c2532e08dff0d4a547b0a707e89f32d.tar.gz netapp-44bbc1c00c2532e08dff0d4a547b0a707e89f32d.zip |
Rename AutoSerialize into SimpleMessage and refactor a bit
Diffstat (limited to 'src/util.rs')
-rw-r--r-- | src/util.rs | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/util.rs b/src/util.rs index e81a89c..f860672 100644 --- a/src/util.rs +++ b/src/util.rs @@ -2,9 +2,9 @@ use std::net::SocketAddr; use std::net::ToSocketAddrs; use std::pin::Pin; +use bytes::Bytes; use log::info; use serde::Serialize; -use bytes::Bytes; use futures::Stream; use tokio::sync::watch; @@ -35,19 +35,16 @@ pub type Packet = Result<Bytes, u8>; /// /// Field names and variant names are included in the serialization. /// This is used internally by the netapp communication protocol. -pub fn rmp_to_vec_all_named<T>( - val: &T, -) -> Result<(Vec<u8>, Option<ByteStream>), rmp_serde::encode::Error> +pub fn rmp_to_vec_all_named<T>(val: &T) -> Result<Vec<u8>, rmp_serde::encode::Error> where - T: SerializeMessage + ?Sized, + T: Serialize + ?Sized, { let mut wr = Vec::with_capacity(128); let mut se = rmp_serde::Serializer::new(&mut wr) .with_struct_map() .with_string_variants(); - let (val, stream) = val.serialize_msg(); val.serialize(&mut se)?; - Ok((wr, stream)) + Ok(wr) } /// This async function returns only when a true signal was received |