module Sound.OSC.Coding.Class where
import qualified Data.ByteString as Strict
import qualified Data.ByteString.Lazy as Lazy
import Sound.OSC.Packet
import qualified Sound.OSC.Coding.Decode.Binary as Binary
import qualified Sound.OSC.Coding.Encode.Builder as Builder
class Coding a where
encodePacket :: Packet -> a
decodePacket :: a -> Packet
instance Coding Strict.ByteString where
encodePacket = Builder.encodePacket_strict
decodePacket = Binary.decodePacket_strict
instance Coding Lazy.ByteString where
encodePacket = Builder.encodePacket
decodePacket = Binary.decodePacket
encodeMessage :: Coding c => Message -> c
encodeMessage = encodePacket . Packet_Message
encodeBundle :: Coding c => Bundle -> c
encodeBundle = encodePacket . Packet_Bundle
decodeMessage :: Coding c => c -> Maybe Message
decodeMessage = packet_to_message . decodePacket
decodeBundle :: Coding c => c -> Bundle
decodeBundle = packet_to_bundle . decodePacket