diff options
author | Alyssa Ross <hi@alyssa.is> | 2020-04-10 13:04:17 +0000 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2020-06-15 09:37:27 +0000 |
commit | aa9ee49fdf908aef32d4363704099a0584834d4c (patch) | |
tree | d6f41d2835166d040a6a4c842ec54da9ace103b2 | |
parent | a201fd46bd0549655b85bcd6e609fdabd1add837 (diff) | |
download | crosvm-aa9ee49fdf908aef32d4363704099a0584834d4c.tar crosvm-aa9ee49fdf908aef32d4363704099a0584834d4c.tar.gz crosvm-aa9ee49fdf908aef32d4363704099a0584834d4c.tar.bz2 crosvm-aa9ee49fdf908aef32d4363704099a0584834d4c.tar.lz crosvm-aa9ee49fdf908aef32d4363704099a0584834d4c.tar.xz crosvm-aa9ee49fdf908aef32d4363704099a0584834d4c.tar.zst crosvm-aa9ee49fdf908aef32d4363704099a0584834d4c.zip |
msg_socket2: add serialize_newtype_variant
-rw-r--r-- | msg_socket2/src/ser.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/msg_socket2/src/ser.rs b/msg_socket2/src/ser.rs index 8be85aa..78ea1e6 100644 --- a/msg_socket2/src/ser.rs +++ b/msg_socket2/src/ser.rs @@ -353,6 +353,16 @@ pub trait FdSerializer<'fds>: Sized { variant: &'static str, ) -> Result<Self::Ok, Self::Error>; + /// Like `Serializer::serialize_newtype_variant`, but `value` is a + /// `SerializeWithFds` instead of a `Serialize`. + fn serialize_newtype_variant<T: SerializeWithFds + ?Sized>( + self, + name: &'static str, + variant_index: u32, + variant: &'static str, + value: &'fds T, + ) -> Result<Self::Ok, Self::Error>; + /// Like `Serializer::serialize_seq`, but returns a /// `SerializeSeqFds`, which serializes file descriptors as well /// as data. @@ -448,6 +458,16 @@ impl<'ser, 'fds: 'ser> FdSerializer<'fds> for &'ser mut FdSerializerImpl<'fds> { Ok(()) } + fn serialize_newtype_variant<T: SerializeWithFds + ?Sized>( + self, + _name: &'static str, + _variant_index: u32, + _variant: &'static str, + value: &'fds T, + ) -> Result<Self::Ok, Self::Error> { + value.serialize_fds(self) + } + fn serialize_seq(self, _len: Option<usize>) -> Result<Self::SerializeSeqFds, Self::Error> { Ok(Composite { serializer: self }) } |