Closed xy2i closed 1 year ago
:exclamation: No coverage uploaded for pull request base (
main@6d40763
). Click here to learn what that means. Patch coverage: 51.63% of modified lines in pull request are covered.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Thank you for your review !
I ran into an issue I feel like is blocking, which I couldn't work around (see the review above). If there's no good work around I'm okay closing this PR, but let me know.
@xy2i oh silly me... Yeah I forgot that const generics is very minimal right now. But this is no reason to not merge your PR. There might be an alternative but I'm not sure how well it works:
mod sealed {
pub trait DeSerializeBytes {}
impl<const N: usize> DeSerializeBytes for [u8; N] {}
}
pub trait DeSerialize {
type Bytes: sealed::DeSerializeBytes;
fn serialize(&self) -> Self::Bytes;
fn deserialize(bytes: Self::Bytes) -> Self;
}
impl DeSerialize for i32 {
type Bytes = [u8; std::mem::size_of::<Self>()];
fn serialize(&self) -> Self::Bytes {
self.to_ne_bytes()
}
fn deserialize(bytes: Self::Bytes) -> Self {
Self::from_ne_bytes(bytes)
}
}
Let me know if you think that's good enough. Otherwise, we can merge this as it is I think :)
Thanks!
That works, thanks !
Thanks for this!
We use
UnixStream::pair()
a few times and reimplement binary ser/de each time. Add an abstraction that does the serde (BinSerDe
) and buffer ceremony (BinPipe
) for us.Fixes #471.