module Rattletrap.Encode.Replay
  ( putReplay
  )
where

import Rattletrap.Encode.Content
import Rattletrap.Encode.Header
import Rattletrap.Encode.Section
import Rattletrap.Type.Replay

import qualified Data.Binary as Binary

-- | Generates a raw replay. Use this with 'Data.Binary.Put.runPut'.
--
-- @
-- let bytes = 'Data.Binary.Put.runPut' ('putReplay' replay)
-- @
putReplay :: FullReplay -> Binary.Put
putReplay :: FullReplay -> Put
putReplay FullReplay
replay = do
  (Header -> Put) -> Section Header -> Put
forall a. (a -> Put) -> Section a -> Put
putSection Header -> Put
putHeader (FullReplay -> Section Header
forall content. Replay content -> Section Header
replayHeader FullReplay
replay)
  (Content -> Put) -> Section Content -> Put
forall a. (a -> Put) -> Section a -> Put
putSection Content -> Put
putContent (FullReplay -> Section Content
forall content. Replay content -> Section content
replayContent FullReplay
replay)