module Rattletrap.Type.Attribute.Byte where import qualified Rattletrap.BitGet as BitGet import qualified Rattletrap.BitPut as BitPut import qualified Rattletrap.Schema as Schema import qualified Rattletrap.Type.U8 as U8 import qualified Rattletrap.Utility.Json as Json newtype Byte = Byte { Byte -> U8 value :: U8.U8 } deriving (Byte -> Byte -> Bool (Byte -> Byte -> Bool) -> (Byte -> Byte -> Bool) -> Eq Byte forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a /= :: Byte -> Byte -> Bool $c/= :: Byte -> Byte -> Bool == :: Byte -> Byte -> Bool $c== :: Byte -> Byte -> Bool Eq, Int -> Byte -> ShowS [Byte] -> ShowS Byte -> String (Int -> Byte -> ShowS) -> (Byte -> String) -> ([Byte] -> ShowS) -> Show Byte forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a showList :: [Byte] -> ShowS $cshowList :: [Byte] -> ShowS show :: Byte -> String $cshow :: Byte -> String showsPrec :: Int -> Byte -> ShowS $cshowsPrec :: Int -> Byte -> ShowS Show) instance Json.FromJSON Byte where parseJSON :: Value -> Parser Byte parseJSON = (U8 -> Byte) -> Parser U8 -> Parser Byte forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b fmap U8 -> Byte Byte (Parser U8 -> Parser Byte) -> (Value -> Parser U8) -> Value -> Parser Byte forall b c a. (b -> c) -> (a -> b) -> a -> c . Value -> Parser U8 forall a. FromJSON a => Value -> Parser a Json.parseJSON instance Json.ToJSON Byte where toJSON :: Byte -> Value toJSON = U8 -> Value forall a. ToJSON a => a -> Value Json.toJSON (U8 -> Value) -> (Byte -> U8) -> Byte -> Value forall b c a. (b -> c) -> (a -> b) -> a -> c . Byte -> U8 value schema :: Schema.Schema schema :: Schema schema = String -> Value -> Schema Schema.named String "attribute-byte" (Value -> Schema) -> Value -> Schema forall a b. (a -> b) -> a -> b $ Schema -> Value Schema.ref Schema U8.schema bitPut :: Byte -> BitPut.BitPut bitPut :: Byte -> BitPut bitPut Byte byteAttribute = U8 -> BitPut U8.bitPut (Byte -> U8 value Byte byteAttribute) bitGet :: BitGet.BitGet Byte bitGet :: BitGet Byte bitGet = U8 -> Byte Byte (U8 -> Byte) -> BitGet U8 -> BitGet Byte forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> BitGet U8 U8.bitGet