module Rattletrap.Type.RemoteId.Steam where

import qualified Rattletrap.BitGet as BitGet
import qualified Rattletrap.BitPut as BitPut
import qualified Rattletrap.Schema as Schema
import qualified Rattletrap.Type.U64 as U64
import qualified Rattletrap.Utility.Json as Json

newtype Steam
  = Steam U64.U64
  deriving (Steam -> Steam -> Bool
(Steam -> Steam -> Bool) -> (Steam -> Steam -> Bool) -> Eq Steam
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Steam -> Steam -> Bool
$c/= :: Steam -> Steam -> Bool
== :: Steam -> Steam -> Bool
$c== :: Steam -> Steam -> Bool
Eq, Int -> Steam -> ShowS
[Steam] -> ShowS
Steam -> String
(Int -> Steam -> ShowS)
-> (Steam -> String) -> ([Steam] -> ShowS) -> Show Steam
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Steam] -> ShowS
$cshowList :: [Steam] -> ShowS
show :: Steam -> String
$cshow :: Steam -> String
showsPrec :: Int -> Steam -> ShowS
$cshowsPrec :: Int -> Steam -> ShowS
Show)

instance Json.FromJSON Steam where
  parseJSON :: Value -> Parser Steam
parseJSON = (U64 -> Steam) -> Parser U64 -> Parser Steam
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap U64 -> Steam
fromU64 (Parser U64 -> Parser Steam)
-> (Value -> Parser U64) -> Value -> Parser Steam
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Parser U64
forall a. FromJSON a => Value -> Parser a
Json.parseJSON

instance Json.ToJSON Steam where
  toJSON :: Steam -> Value
toJSON = U64 -> Value
forall a. ToJSON a => a -> Value
Json.toJSON (U64 -> Value) -> (Steam -> U64) -> Steam -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Steam -> U64
toU64

fromU64 :: U64.U64 -> Steam
fromU64 :: U64 -> Steam
fromU64 = U64 -> Steam
Steam

toU64 :: Steam -> U64.U64
toU64 :: Steam -> U64
toU64 (Steam U64
x) = U64
x

schema :: Schema.Schema
schema :: Schema
schema = Schema
U64.schema

bitPut :: Steam -> BitPut.BitPut
bitPut :: Steam -> BitPut
bitPut = U64 -> BitPut
U64.bitPut (U64 -> BitPut) -> (Steam -> U64) -> Steam -> BitPut
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Steam -> U64
toU64

bitGet :: BitGet.BitGet Steam
bitGet :: BitGet Steam
bitGet = String -> BitGet Steam -> BitGet Steam
forall a. String -> BitGet a -> BitGet a
BitGet.label String
"Steam" (BitGet Steam -> BitGet Steam) -> BitGet Steam -> BitGet Steam
forall a b. (a -> b) -> a -> b
$ (U64 -> Steam) -> Get BitString Identity U64 -> BitGet Steam
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap U64 -> Steam
fromU64 Get BitString Identity U64
U64.bitGet