module Rattletrap.Type.AttributeMapping where import qualified Rattletrap.ByteGet as ByteGet import qualified Rattletrap.BytePut as BytePut import qualified Rattletrap.Schema as Schema import qualified Rattletrap.Type.U32 as U32 import qualified Rattletrap.Utility.Json as Json data AttributeMapping = AttributeMapping { AttributeMapping -> U32 objectId :: U32.U32 , AttributeMapping -> U32 streamId :: U32.U32 } deriving (AttributeMapping -> AttributeMapping -> Bool forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a /= :: AttributeMapping -> AttributeMapping -> Bool $c/= :: AttributeMapping -> AttributeMapping -> Bool == :: AttributeMapping -> AttributeMapping -> Bool $c== :: AttributeMapping -> AttributeMapping -> Bool Eq, Int -> AttributeMapping -> ShowS [AttributeMapping] -> ShowS AttributeMapping -> String forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a showList :: [AttributeMapping] -> ShowS $cshowList :: [AttributeMapping] -> ShowS show :: AttributeMapping -> String $cshow :: AttributeMapping -> String showsPrec :: Int -> AttributeMapping -> ShowS $cshowsPrec :: Int -> AttributeMapping -> ShowS Show) instance Json.FromJSON AttributeMapping where parseJSON :: Value -> Parser AttributeMapping parseJSON = forall a. String -> (Object -> Parser a) -> Value -> Parser a Json.withObject String "AttributeMapping" forall a b. (a -> b) -> a -> b $ \Object object -> do U32 objectId <- forall value. FromJSON value => Object -> String -> Parser value Json.required Object object String "object_id" U32 streamId <- forall value. FromJSON value => Object -> String -> Parser value Json.required Object object String "stream_id" forall (f :: * -> *) a. Applicative f => a -> f a pure AttributeMapping { U32 objectId :: U32 objectId :: U32 objectId, U32 streamId :: U32 streamId :: U32 streamId } instance Json.ToJSON AttributeMapping where toJSON :: AttributeMapping -> Value toJSON AttributeMapping x = [(Key, Value)] -> Value Json.object [forall value pair. (ToJSON value, KeyValue pair) => String -> value -> pair Json.pair String "object_id" forall a b. (a -> b) -> a -> b $ AttributeMapping -> U32 objectId AttributeMapping x, forall value pair. (ToJSON value, KeyValue pair) => String -> value -> pair Json.pair String "stream_id" forall a b. (a -> b) -> a -> b $ AttributeMapping -> U32 streamId AttributeMapping x] schema :: Schema.Schema schema :: Schema schema = String -> Value -> Schema Schema.named String "attributeMapping" forall a b. (a -> b) -> a -> b $ [((Key, Value), Bool)] -> Value Schema.object [ (forall value pair. (ToJSON value, KeyValue pair) => String -> value -> pair Json.pair String "object_id" forall a b. (a -> b) -> a -> b $ Schema -> Value Schema.ref Schema U32.schema, Bool True) , (forall value pair. (ToJSON value, KeyValue pair) => String -> value -> pair Json.pair String "stream_id" forall a b. (a -> b) -> a -> b $ Schema -> Value Schema.ref Schema U32.schema, Bool True) ] bytePut :: AttributeMapping -> BytePut.BytePut bytePut :: AttributeMapping -> BytePut bytePut AttributeMapping x = U32 -> BytePut U32.bytePut (AttributeMapping -> U32 objectId AttributeMapping x) forall a. Semigroup a => a -> a -> a <> U32 -> BytePut U32.bytePut (AttributeMapping -> U32 streamId AttributeMapping x) byteGet :: ByteGet.ByteGet AttributeMapping byteGet :: ByteGet AttributeMapping byteGet = forall a. String -> ByteGet a -> ByteGet a ByteGet.label String "AttributeMapping" forall a b. (a -> b) -> a -> b $ do U32 objectId <- forall a. String -> ByteGet a -> ByteGet a ByteGet.label String "objectId" ByteGet U32 U32.byteGet U32 streamId <- forall a. String -> ByteGet a -> ByteGet a ByteGet.label String "streamId" ByteGet U32 U32.byteGet forall (f :: * -> *) a. Applicative f => a -> f a pure AttributeMapping { U32 objectId :: U32 objectId :: U32 objectId, U32 streamId :: U32 streamId :: U32 streamId }