Created
November 19, 2020 14:36
-
-
Save shymega/e429e7c300ca59a33fc45846834e0339 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![feature(const_fn)] | |
#![feature(const_fn_transmute)] | |
#[derive(restruct_derive::Struct)] | |
#[fmt(">B")] | |
pub(crate) struct U8Serializer; | |
#[derive(restruct_derive::Struct)] | |
#[fmt(">H")] | |
pub(crate) struct U16Serializer; | |
#[derive(restruct_derive::Struct)] | |
#[fmt(">I")] | |
pub(crate) struct U32Serializer; | |
#[derive(restruct_derive::Struct)] | |
#[fmt(">b")] | |
pub(crate) struct I8Serializer; | |
#[derive(restruct_derive::Struct)] | |
#[fmt(">h")] | |
pub(crate) struct I16Serializer; | |
#[derive(restruct_derive::Struct)] | |
#[fmt(">i")] | |
pub(crate) struct I32Serializer; | |
impl U8Serializer { | |
pub(crate) fn encode(val: u8) -> <Self as restruct::Struct>::Packed { | |
Self::pack((val,)) | |
} | |
} | |
impl U16Serializer { | |
pub(crate) fn encode(val: u16) -> <Self as restruct::Struct>::Packed { | |
Self::pack((val,)) | |
} | |
} | |
impl U32Serializer { | |
pub(crate) fn encode2(val: u32) -> <Self as restruct::Struct>::Packed { | |
Self::pack((val,)) | |
} | |
} | |
impl I8Serializer { | |
pub(crate) fn encode(val: i8) -> <Self as restruct::Struct>::Packed { | |
Self::pack((val,)) | |
} | |
} | |
impl I16Serializer { | |
pub(crate) fn encode(val: i16) -> <Self as restruct::Struct>::Packed { | |
Self::pack((val,)) | |
} | |
} | |
impl I32Serializer { | |
pub(crate) fn encode(val: i32) -> <Self as restruct::Struct>::Packed { | |
Self::pack((val,)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment