{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
module Ouroboros.Network.Protocol.ObjectDiffusion.Codec
( codecObjectDiffusion
, codecObjectDiffusionId
, byteLimitsObjectDiffusion
, timeLimitsObjectDiffusion
) where
import Codec.CBOR.Decoding qualified as CBOR
import Codec.CBOR.Encoding qualified as CBOR
import Codec.CBOR.Read qualified as CBOR
import Control.Monad.Class.MonadST
import Control.Monad.Class.MonadTime.SI
import Data.ByteString.Lazy (ByteString)
import Data.Kind (Type)
import Data.List.NonEmpty qualified as NonEmpty
import Data.Singletons (withSingI)
import Formatting (formatToString, (%+))
import Formatting qualified as F
import Network.TypedProtocol.Codec.CBOR
import Ouroboros.Network.Protocol.Limits
import Ouroboros.Network.Protocol.ObjectDiffusion.Type
byteLimitsObjectDiffusion
:: forall bytes objectId object.
SizeInBytes
-> SizeInBytes
-> (bytes -> Word)
-> ProtocolSizeLimits (ObjectDiffusion objectId object) bytes
byteLimitsObjectDiffusion :: forall bytes objectId object.
SizeInBytes
-> SizeInBytes
-> (bytes -> Word)
-> ProtocolSizeLimits (ObjectDiffusion objectId object) bytes
byteLimitsObjectDiffusion SizeInBytes
maxIdsSize SizeInBytes
maxObjectsSize =
(forall (st :: ObjectDiffusion objectId object).
ActiveState st =>
StateToken st -> Word)
-> (bytes -> Word)
-> ProtocolSizeLimits (ObjectDiffusion objectId object) bytes
forall ps bytes.
(forall (st :: ps). ActiveState st => StateToken st -> Word)
-> (bytes -> Word) -> ProtocolSizeLimits ps bytes
ProtocolSizeLimits StateToken st -> Word
forall (st :: ObjectDiffusion objectId object).
ActiveState st =>
StateToken st -> Word
stateToLimit
where
stateToLimit
:: forall (st :: ObjectDiffusion objectId object).
ActiveState st
=> StateToken st
-> Word
stateToLimit :: forall (st :: ObjectDiffusion objectId object).
ActiveState st =>
StateToken st -> Word
stateToLimit StateToken st
SingObjectDiffusion st
SingInit = Word
smallByteLimit
stateToLimit (SingObjectIds SingStObjectIdsKind kind
_) = SizeInBytes -> Word
forall a b. (Integral a, Num b) => a -> b
fromIntegral SizeInBytes
maxIdsSize
stateToLimit StateToken st
SingObjectDiffusion st
SingObjects = SizeInBytes -> Word
forall a b. (Integral a, Num b) => a -> b
fromIntegral SizeInBytes
maxObjectsSize
stateToLimit StateToken st
SingObjectDiffusion st
SingIdle = Word -> Word -> Word
forall a. Ord a => a -> a -> a
max Word
9 (SizeInBytes -> Word
forall a b. (Integral a, Num b) => a -> b
fromIntegral SizeInBytes
maxIdsSize)
stateToLimit a :: StateToken st
a@StateToken st
SingObjectDiffusion st
SingDone = StateToken 'StDone -> forall a. a
forall ps (st :: ps).
(StateAgency st ~ 'NobodyAgency, ActiveState st) =>
StateToken st -> forall a. a
notActiveState StateToken st
StateToken 'StDone
a
timeLimitsObjectDiffusion
:: forall (objectId :: Type) (object :: Type).
ProtocolTimeLimits (ObjectDiffusion objectId object)
timeLimitsObjectDiffusion :: forall objectId object.
ProtocolTimeLimits (ObjectDiffusion objectId object)
timeLimitsObjectDiffusion = (forall (st :: ObjectDiffusion objectId object).
ActiveState st =>
StateToken st -> Maybe DiffTime)
-> ProtocolTimeLimits (ObjectDiffusion objectId object)
forall ps.
(forall (st :: ps).
ActiveState st =>
StateToken st -> Maybe DiffTime)
-> ProtocolTimeLimits ps
ProtocolTimeLimits StateToken st -> Maybe DiffTime
forall (st :: ObjectDiffusion objectId object).
ActiveState st =>
StateToken st -> Maybe DiffTime
stateToLimit
where
stateToLimit
:: forall (st :: ObjectDiffusion objectId object).
ActiveState st
=> StateToken st
-> Maybe DiffTime
stateToLimit :: forall (st :: ObjectDiffusion objectId object).
ActiveState st =>
StateToken st -> Maybe DiffTime
stateToLimit StateToken st
SingObjectDiffusion st
SingInit = Maybe DiffTime
waitForever
stateToLimit (SingObjectIds SingStObjectIdsKind kind
SingObjectIdsNonBlocking) = Maybe DiffTime
shortWait
stateToLimit (SingObjectIds (SingObjectIdsBlocking SingStObjectIdsPhase phase
SingCanAwait)) = Maybe DiffTime
shortWait
stateToLimit (SingObjectIds (SingObjectIdsBlocking SingStObjectIdsPhase phase
SingMustReply)) = Maybe DiffTime
longWait
stateToLimit StateToken st
SingObjectDiffusion st
SingObjects = Maybe DiffTime
shortWait
stateToLimit StateToken st
SingObjectDiffusion st
SingIdle = Maybe DiffTime
waitForever
stateToLimit a :: StateToken st
a@StateToken st
SingObjectDiffusion st
SingDone = StateToken 'StDone -> forall a. a
forall ps (st :: ps).
(StateAgency st ~ 'NobodyAgency, ActiveState st) =>
StateToken st -> forall a. a
notActiveState StateToken st
StateToken 'StDone
a
codecObjectDiffusion
:: forall (objectId :: Type) (object :: Type) m.
MonadST m
=> (objectId -> CBOR.Encoding)
-> (forall s. CBOR.Decoder s objectId)
-> (object -> CBOR.Encoding)
-> (forall s. CBOR.Decoder s object)
-> Codec (ObjectDiffusion objectId object) CBOR.DeserialiseFailure m ByteString
codecObjectDiffusion :: forall objectId object (m :: * -> *).
MonadST m =>
(objectId -> Encoding)
-> (forall s. Decoder s objectId)
-> (object -> Encoding)
-> (forall s. Decoder s object)
-> Codec
(ObjectDiffusion objectId object) DeserialiseFailure m ByteString
codecObjectDiffusion objectId -> Encoding
encodeObjectId forall s. Decoder s objectId
decodeObjectId object -> Encoding
encodeObject forall s. Decoder s object
decodeObject =
(forall (st :: ObjectDiffusion objectId object)
(st' :: ObjectDiffusion objectId object).
(StateTokenI st, ActiveState st) =>
Message (ObjectDiffusion objectId object) st st' -> Encoding)
-> (forall (st :: ObjectDiffusion objectId object) s.
ActiveState st =>
StateToken st -> Decoder s (SomeMessage st))
-> CodecF
(ObjectDiffusion objectId object)
DeserialiseFailure
m
SomeMessage
ByteString
forall ps (m :: * -> *) (f :: ps -> *).
MonadST m =>
(forall (st :: ps) (st' :: ps).
(StateTokenI st, ActiveState st) =>
Message ps st st' -> Encoding)
-> (forall (st :: ps) s.
ActiveState st =>
StateToken st -> Decoder s (f st))
-> CodecF ps DeserialiseFailure m f ByteString
mkCodecCborLazyBS
((objectId -> Encoding)
-> (object -> Encoding)
-> Message (ObjectDiffusion objectId object) st st'
-> Encoding
forall objectId object (st :: ObjectDiffusion objectId object)
(st' :: ObjectDiffusion objectId object).
(objectId -> Encoding)
-> (object -> Encoding)
-> Message (ObjectDiffusion objectId object) st st'
-> Encoding
encodeObjectDiffusion objectId -> Encoding
encodeObjectId object -> Encoding
encodeObject)
StateToken st -> Decoder s (SomeMessage st)
StateToken st -> forall s. Decoder s (SomeMessage st)
forall (st :: ObjectDiffusion objectId object).
ActiveState st =>
StateToken st -> forall s. Decoder s (SomeMessage st)
forall (st :: ObjectDiffusion objectId object) s.
ActiveState st =>
StateToken st -> Decoder s (SomeMessage st)
decode
where
decode
:: forall (st :: ObjectDiffusion objectId object).
ActiveState st
=> StateToken st
-> forall s. CBOR.Decoder s (SomeMessage st)
decode :: forall (st :: ObjectDiffusion objectId object).
ActiveState st =>
StateToken st -> forall s. Decoder s (SomeMessage st)
decode StateToken st
stok = do
len <- Decoder s Int
forall s. Decoder s Int
CBOR.decodeListLen
key <- CBOR.decodeWord
decodeObjectDiffusion decodeObjectId decodeObject stok len key
encodeObjectDiffusion
:: forall (objectId :: Type) (object :: Type)
(st :: ObjectDiffusion objectId object)
(st' :: ObjectDiffusion objectId object).
(objectId -> CBOR.Encoding)
-> (object -> CBOR.Encoding)
-> Message (ObjectDiffusion objectId object) st st'
-> CBOR.Encoding
encodeObjectDiffusion :: forall objectId object (st :: ObjectDiffusion objectId object)
(st' :: ObjectDiffusion objectId object).
(objectId -> Encoding)
-> (object -> Encoding)
-> Message (ObjectDiffusion objectId object) st st'
-> Encoding
encodeObjectDiffusion objectId -> Encoding
encodeObjectId object -> Encoding
encodeObject = Message (ObjectDiffusion objectId object) st st' -> Encoding
forall (st0 :: ObjectDiffusion objectId object)
(st1 :: ObjectDiffusion objectId object).
Message (ObjectDiffusion objectId object) st0 st1 -> Encoding
encode
where
encode
:: forall st0 st1.
Message (ObjectDiffusion objectId object) st0 st1
-> CBOR.Encoding
encode :: forall (st0 :: ObjectDiffusion objectId object)
(st1 :: ObjectDiffusion objectId object).
Message (ObjectDiffusion objectId object) st0 st1 -> Encoding
encode Message (ObjectDiffusion objectId object) st0 st1
R:MessageObjectDiffusionfromto objectId object st0 st1
MsgInit =
Word -> Encoding
CBOR.encodeListLen Word
1
Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Word -> Encoding
CBOR.encodeWord Word
0
encode (MsgRequestObjectIds SingObjectIdsRequestKind kind
requestKind (NumObjectIdsAck Word16
ackNo) (NumObjectIdsReq Word16
reqNo)) =
Word -> Encoding
CBOR.encodeListLen Word
4
Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Word -> Encoding
CBOR.encodeWord Word
1
Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Bool -> Encoding
CBOR.encodeBool
( case SingObjectIdsRequestKind kind
requestKind of
SingObjectIdsRequestKind kind
SingRequestObjectIdsBlocking -> Bool
True
SingObjectIdsRequestKind kind
SingRequestObjectIdsNonBlocking -> Bool
False
)
Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Word16 -> Encoding
CBOR.encodeWord16 Word16
ackNo
Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Word16 -> Encoding
CBOR.encodeWord16 Word16
reqNo
encode (MsgReplyObjectIds ObjectIdsReplyList kind objectId
objIds) =
Word -> Encoding
CBOR.encodeListLen Word
2
Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Word -> Encoding
CBOR.encodeWord Word
2
Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Encoding
CBOR.encodeListLenIndef
Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> (objectId -> Encoding)
-> ObjectIdsReplyList kind objectId -> Encoding
forall m a. Monoid m => (a -> m) -> ObjectIdsReplyList kind a -> m
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap objectId -> Encoding
encodeObjectId ObjectIdsReplyList kind objectId
objIds
Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Encoding
CBOR.encodeBreak
encode (MsgRequestObjects [objectId]
objIds) =
Word -> Encoding
CBOR.encodeListLen Word
2
Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Word -> Encoding
CBOR.encodeWord Word
3
Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Encoding
CBOR.encodeListLenIndef
Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> (objectId -> Encoding) -> [objectId] -> Encoding
forall m a. Monoid m => (a -> m) -> [a] -> m
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap objectId -> Encoding
encodeObjectId [objectId]
objIds
Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Encoding
CBOR.encodeBreak
encode (MsgReplyObjects [object]
objects) =
Word -> Encoding
CBOR.encodeListLen Word
2
Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Word -> Encoding
CBOR.encodeWord Word
4
Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Encoding
CBOR.encodeListLenIndef
Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> (object -> Encoding) -> [object] -> Encoding
forall m a. Monoid m => (a -> m) -> [a] -> m
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap object -> Encoding
encodeObject [object]
objects
Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Encoding
CBOR.encodeBreak
encode Message (ObjectDiffusion objectId object) st0 st1
R:MessageObjectDiffusionfromto objectId object st0 st1
MsgDone =
Word -> Encoding
CBOR.encodeListLen Word
1
Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Word -> Encoding
CBOR.encodeWord Word
5
encode Message (ObjectDiffusion objectId object) st0 st1
R:MessageObjectDiffusionfromto objectId object st0 st1
MsgServerIdle =
Word -> Encoding
CBOR.encodeListLen Word
1
Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Word -> Encoding
CBOR.encodeWord Word
6
encode Message (ObjectDiffusion objectId object) st0 st1
R:MessageObjectDiffusionfromto objectId object st0 st1
MsgAwaitReply =
Word -> Encoding
CBOR.encodeListLen Word
1
Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Word -> Encoding
CBOR.encodeWord Word
7
decodeObjectDiffusion
:: forall (objectId :: Type) (object :: Type)
(st :: ObjectDiffusion objectId object) s.
ActiveState st
=> (forall s'. CBOR.Decoder s' objectId)
-> (forall s'. CBOR.Decoder s' object)
-> StateToken st
-> Int
-> Word
-> CBOR.Decoder s (SomeMessage st)
decodeObjectDiffusion :: forall objectId object (st :: ObjectDiffusion objectId object) s.
ActiveState st =>
(forall s'. Decoder s' objectId)
-> (forall s'. Decoder s' object)
-> StateToken st
-> Int
-> Word
-> Decoder s (SomeMessage st)
decodeObjectDiffusion forall s'. Decoder s' objectId
decodeObjectId forall s'. Decoder s' object
decodeObject = StateToken st -> Int -> Word -> Decoder s (SomeMessage st)
forall (st' :: ObjectDiffusion objectId object).
ActiveState st' =>
StateToken st' -> Int -> Word -> Decoder s (SomeMessage st')
decode
where
decode
:: forall (st' :: ObjectDiffusion objectId object).
ActiveState st'
=> StateToken st'
-> Int
-> Word
-> CBOR.Decoder s (SomeMessage st')
decode :: forall (st' :: ObjectDiffusion objectId object).
ActiveState st' =>
StateToken st' -> Int -> Word -> Decoder s (SomeMessage st')
decode StateToken st'
stok Int
len Word
key = do
case (StateToken st'
SingObjectDiffusion st'
stok, Int
len, Word
key) of
(SingObjectDiffusion st'
SingInit, Int
1, Word
0) ->
SomeMessage st' -> Decoder s (SomeMessage st')
forall a. a -> Decoder s a
forall (m :: * -> *) a. Monad m => a -> m a
return (SomeMessage st' -> Decoder s (SomeMessage st'))
-> SomeMessage st' -> Decoder s (SomeMessage st')
forall a b. (a -> b) -> a -> b
$ Message (ObjectDiffusion objectId object) st' 'StIdle
-> SomeMessage st'
forall ps (st :: ps) (st' :: ps).
(StateTokenI st, StateTokenI st', ActiveState st) =>
Message ps st st' -> SomeMessage st
SomeMessage Message (ObjectDiffusion objectId object) st' 'StIdle
Message (ObjectDiffusion objectId object) 'StInit 'StIdle
forall objectId object.
Message (ObjectDiffusion objectId object) 'StInit 'StIdle
MsgInit
(SingObjectDiffusion st'
SingIdle, Int
4, Word
1) -> do
blocking <- Decoder s Bool
forall s. Decoder s Bool
CBOR.decodeBool
ackNo <- NumObjectIdsAck <$> CBOR.decodeWord16
reqNo <- NumObjectIdsReq <$> CBOR.decodeWord16
return $! if blocking
then SomeMessage $ MsgRequestObjectIds SingRequestObjectIdsBlocking ackNo reqNo
else SomeMessage $ MsgRequestObjectIds SingRequestObjectIdsNonBlocking ackNo reqNo
(SingObjectIds SingStObjectIdsKind kind
singKind, Int
2, Word
2) -> Sing kind
-> (SingI kind => Decoder s (SomeMessage st'))
-> Decoder s (SomeMessage st')
forall {k} (n :: k) r. Sing n -> (SingI n => r) -> r
withSingI Sing kind
SingStObjectIdsKind kind
singKind ((SingI kind => Decoder s (SomeMessage st'))
-> Decoder s (SomeMessage st'))
-> (SingI kind => Decoder s (SomeMessage st'))
-> Decoder s (SomeMessage st')
forall a b. (a -> b) -> a -> b
$ do
Decoder s ()
forall s. Decoder s ()
CBOR.decodeListLenIndef
objIds <- ([objectId] -> objectId -> [objectId])
-> [objectId]
-> ([objectId] -> [objectId])
-> Decoder s objectId
-> Decoder s [objectId]
forall r a r' s.
(r -> a -> r) -> r -> (r -> r') -> Decoder s a -> Decoder s r'
CBOR.decodeSequenceLenIndef
((objectId -> [objectId] -> [objectId])
-> [objectId] -> objectId -> [objectId]
forall a b c. (a -> b -> c) -> b -> a -> c
flip (:))
[]
[objectId] -> [objectId]
forall a. [a] -> [a]
reverse
Decoder s objectId
forall s'. Decoder s' objectId
decodeObjectId
case (singKind, objIds) of
(SingObjectIdsBlocking SingStObjectIdsPhase phase
_, objectId
t : [objectId]
ts) ->
SomeMessage st' -> Decoder s (SomeMessage st')
forall a. a -> Decoder s a
forall (m :: * -> *) a. Monad m => a -> m a
return
(SomeMessage st' -> Decoder s (SomeMessage st'))
-> SomeMessage st' -> Decoder s (SomeMessage st')
forall a b. (a -> b) -> a -> b
$ Message (ObjectDiffusion objectId object) st' 'StIdle
-> SomeMessage st'
forall ps (st :: ps) (st' :: ps).
(StateTokenI st, StateTokenI st', ActiveState st) =>
Message ps st st' -> SomeMessage st
SomeMessage
(Message (ObjectDiffusion objectId object) st' 'StIdle
-> SomeMessage st')
-> Message (ObjectDiffusion objectId object) st' 'StIdle
-> SomeMessage st'
forall a b. (a -> b) -> a -> b
$ ObjectIdsReplyList ('StObjectIdsBlocking phase) objectId
-> Message
(ObjectDiffusion objectId object)
('StObjectIds ('StObjectIdsBlocking phase))
'StIdle
forall (kind :: StObjectIdsKind) objectId object.
ObjectIdsReplyList kind objectId
-> Message
(ObjectDiffusion objectId object) ('StObjectIds kind) 'StIdle
MsgReplyObjectIds (NonEmpty objectId
-> ObjectIdsReplyList ('StObjectIdsBlocking phase) objectId
forall a (phase :: StObjectIdsPhase).
NonEmpty a -> ObjectIdsReplyList ('StObjectIdsBlocking phase) a
BlockingReply (objectId
t objectId -> [objectId] -> NonEmpty objectId
forall a. a -> [a] -> NonEmpty a
NonEmpty.:| [objectId]
ts))
(SingStObjectIdsKind kind
SingObjectIdsNonBlocking, [objectId]
ts) ->
SomeMessage st' -> Decoder s (SomeMessage st')
forall a. a -> Decoder s a
forall (m :: * -> *) a. Monad m => a -> m a
return
(SomeMessage st' -> Decoder s (SomeMessage st'))
-> SomeMessage st' -> Decoder s (SomeMessage st')
forall a b. (a -> b) -> a -> b
$ Message (ObjectDiffusion objectId object) st' 'StIdle
-> SomeMessage st'
forall ps (st :: ps) (st' :: ps).
(StateTokenI st, StateTokenI st', ActiveState st) =>
Message ps st st' -> SomeMessage st
SomeMessage
(Message (ObjectDiffusion objectId object) st' 'StIdle
-> SomeMessage st')
-> Message (ObjectDiffusion objectId object) st' 'StIdle
-> SomeMessage st'
forall a b. (a -> b) -> a -> b
$ ObjectIdsReplyList 'StObjectIdsNonBlocking objectId
-> Message
(ObjectDiffusion objectId object)
('StObjectIds 'StObjectIdsNonBlocking)
'StIdle
forall (kind :: StObjectIdsKind) objectId object.
ObjectIdsReplyList kind objectId
-> Message
(ObjectDiffusion objectId object) ('StObjectIds kind) 'StIdle
MsgReplyObjectIds ([objectId] -> ObjectIdsReplyList 'StObjectIdsNonBlocking objectId
forall a. [a] -> ObjectIdsReplyList 'StObjectIdsNonBlocking a
NonBlockingReply [objectId]
ts)
(SingObjectIdsBlocking SingStObjectIdsPhase phase
_, []) ->
String -> Decoder s (SomeMessage st')
forall a. String -> Decoder s a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"codecObjectDiffusion: MsgReplyObjectIds: empty list not permitted"
(SingObjectDiffusion st'
SingIdle, Int
2, Word
3) -> do
Decoder s ()
forall s. Decoder s ()
CBOR.decodeListLenIndef
objIds <- ([objectId] -> objectId -> [objectId])
-> [objectId]
-> ([objectId] -> [objectId])
-> Decoder s objectId
-> Decoder s [objectId]
forall r a r' s.
(r -> a -> r) -> r -> (r -> r') -> Decoder s a -> Decoder s r'
CBOR.decodeSequenceLenIndef
((objectId -> [objectId] -> [objectId])
-> [objectId] -> objectId -> [objectId]
forall a b c. (a -> b -> c) -> b -> a -> c
flip (:))
[]
[objectId] -> [objectId]
forall a. [a] -> [a]
reverse
Decoder s objectId
forall s'. Decoder s' objectId
decodeObjectId
return $ SomeMessage $ MsgRequestObjects objIds
(SingObjectDiffusion st'
SingObjects, Int
2, Word
4) -> do
Decoder s ()
forall s. Decoder s ()
CBOR.decodeListLenIndef
objIds <- ([object] -> object -> [object])
-> [object]
-> ([object] -> [object])
-> Decoder s object
-> Decoder s [object]
forall r a r' s.
(r -> a -> r) -> r -> (r -> r') -> Decoder s a -> Decoder s r'
CBOR.decodeSequenceLenIndef
((object -> [object] -> [object]) -> [object] -> object -> [object]
forall a b c. (a -> b -> c) -> b -> a -> c
flip (:))
[]
[object] -> [object]
forall a. [a] -> [a]
reverse
Decoder s object
forall s'. Decoder s' object
decodeObject
return $ SomeMessage $ MsgReplyObjects objIds
(SingObjectDiffusion st'
SingIdle, Int
1, Word
5) ->
SomeMessage st' -> Decoder s (SomeMessage st')
forall a. a -> Decoder s a
forall (m :: * -> *) a. Monad m => a -> m a
return (SomeMessage st' -> Decoder s (SomeMessage st'))
-> SomeMessage st' -> Decoder s (SomeMessage st')
forall a b. (a -> b) -> a -> b
$ Message (ObjectDiffusion objectId object) st' 'StDone
-> SomeMessage st'
forall ps (st :: ps) (st' :: ps).
(StateTokenI st, StateTokenI st', ActiveState st) =>
Message ps st st' -> SomeMessage st
SomeMessage Message (ObjectDiffusion objectId object) st' 'StDone
Message (ObjectDiffusion objectId object) 'StIdle 'StDone
forall objectId object.
Message (ObjectDiffusion objectId object) 'StIdle 'StDone
MsgDone
(SingObjectIds (SingObjectIdsBlocking SingStObjectIdsPhase phase
SingMustReply), Int
1, Word
6) ->
SomeMessage st' -> Decoder s (SomeMessage st')
forall a. a -> Decoder s a
forall (m :: * -> *) a. Monad m => a -> m a
return (SomeMessage st' -> Decoder s (SomeMessage st'))
-> SomeMessage st' -> Decoder s (SomeMessage st')
forall a b. (a -> b) -> a -> b
$ Message (ObjectDiffusion objectId object) st' 'StIdle
-> SomeMessage st'
forall ps (st :: ps) (st' :: ps).
(StateTokenI st, StateTokenI st', ActiveState st) =>
Message ps st st' -> SomeMessage st
SomeMessage Message (ObjectDiffusion objectId object) st' 'StIdle
Message
(ObjectDiffusion objectId object)
('StObjectIds ('StObjectIdsBlocking 'StMustReply))
'StIdle
forall objectId object.
Message
(ObjectDiffusion objectId object)
('StObjectIds ('StObjectIdsBlocking 'StMustReply))
'StIdle
MsgServerIdle
(SingObjectIds (SingObjectIdsBlocking SingStObjectIdsPhase phase
SingCanAwait), Int
1, Word
7) ->
SomeMessage st' -> Decoder s (SomeMessage st')
forall a. a -> Decoder s a
forall (m :: * -> *) a. Monad m => a -> m a
return (SomeMessage st' -> Decoder s (SomeMessage st'))
-> SomeMessage st' -> Decoder s (SomeMessage st')
forall a b. (a -> b) -> a -> b
$ Message
(ObjectDiffusion objectId object)
st'
('StObjectIds ('StObjectIdsBlocking 'StMustReply))
-> SomeMessage st'
forall ps (st :: ps) (st' :: ps).
(StateTokenI st, StateTokenI st', ActiveState st) =>
Message ps st st' -> SomeMessage st
SomeMessage Message
(ObjectDiffusion objectId object)
st'
('StObjectIds ('StObjectIdsBlocking 'StMustReply))
Message
(ObjectDiffusion objectId object)
('StObjectIds ('StObjectIdsBlocking 'StCanAwait))
('StObjectIds ('StObjectIdsBlocking 'StMustReply))
forall objectId object.
Message
(ObjectDiffusion objectId object)
('StObjectIds ('StObjectIdsBlocking 'StCanAwait))
('StObjectIds ('StObjectIdsBlocking 'StMustReply))
MsgAwaitReply
(SingObjectDiffusion st'
SingDone, Int
_, Word
_) -> StateToken 'StDone -> forall a. a
forall ps (st :: ps).
(StateAgency st ~ 'NobodyAgency, ActiveState st) =>
StateToken st -> forall a. a
notActiveState StateToken st'
StateToken 'StDone
stok
(SingObjectDiffusion st'
SingInit, Int
_, Word
_) ->
String -> Decoder s (SomeMessage st')
forall a. String -> Decoder s a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (Format
String
(ActiveAgency' st' (StateAgency st')
-> SingObjectDiffusion st' -> Word -> Int -> String)
-> ActiveAgency' st' (StateAgency st')
-> SingObjectDiffusion st'
-> Word
-> Int
-> String
forall a. Format String a -> a
formatToString Format
String
(ActiveAgency' st' (StateAgency st')
-> StateToken st' -> Word -> Int -> String)
Format
String
(ActiveAgency' st' (StateAgency st')
-> SingObjectDiffusion st' -> Word -> Int -> String)
forall (st' :: ObjectDiffusion objectId object) r.
Format r (ActiveAgency st' -> StateToken st' -> Word -> Int -> r)
fmterr (ActiveAgency' st' 'ClientAgency
ActiveAgency' st' (StateAgency st')
forall {ps} (st :: ps) (agency :: Agency).
IsActiveState st agency =>
ActiveAgency' st agency
activeAgency :: ActiveAgency st') StateToken st'
SingObjectDiffusion st'
stok Word
key Int
len)
(SingObjectIds SingStObjectIdsKind kind
_, Int
_, Word
_) ->
String -> Decoder s (SomeMessage st')
forall a. String -> Decoder s a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (Format
String
(ActiveAgency' st' (StateAgency st')
-> SingObjectDiffusion st' -> Word -> Int -> String)
-> ActiveAgency' st' (StateAgency st')
-> SingObjectDiffusion st'
-> Word
-> Int
-> String
forall a. Format String a -> a
formatToString Format
String
(ActiveAgency' st' (StateAgency st')
-> StateToken st' -> Word -> Int -> String)
Format
String
(ActiveAgency' st' (StateAgency st')
-> SingObjectDiffusion st' -> Word -> Int -> String)
forall (st' :: ObjectDiffusion objectId object) r.
Format r (ActiveAgency st' -> StateToken st' -> Word -> Int -> r)
fmterr (ActiveAgency' st' 'ServerAgency
ActiveAgency' st' (StateAgency st')
forall {ps} (st :: ps) (agency :: Agency).
IsActiveState st agency =>
ActiveAgency' st agency
activeAgency :: ActiveAgency st') StateToken st'
SingObjectDiffusion st'
stok Word
key Int
len)
(SingObjectDiffusion st'
SingObjects, Int
_, Word
_) ->
String -> Decoder s (SomeMessage st')
forall a. String -> Decoder s a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (Format
String
(ActiveAgency' st' (StateAgency st')
-> SingObjectDiffusion st' -> Word -> Int -> String)
-> ActiveAgency' st' (StateAgency st')
-> SingObjectDiffusion st'
-> Word
-> Int
-> String
forall a. Format String a -> a
formatToString Format
String
(ActiveAgency' st' (StateAgency st')
-> StateToken st' -> Word -> Int -> String)
Format
String
(ActiveAgency' st' (StateAgency st')
-> SingObjectDiffusion st' -> Word -> Int -> String)
forall (st' :: ObjectDiffusion objectId object) r.
Format r (ActiveAgency st' -> StateToken st' -> Word -> Int -> r)
fmterr (ActiveAgency' st' 'ServerAgency
ActiveAgency' st' (StateAgency st')
forall {ps} (st :: ps) (agency :: Agency).
IsActiveState st agency =>
ActiveAgency' st agency
activeAgency :: ActiveAgency st') StateToken st'
SingObjectDiffusion st'
stok Word
key Int
len)
(SingObjectDiffusion st'
SingIdle, Int
_, Word
_) ->
String -> Decoder s (SomeMessage st')
forall a. String -> Decoder s a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (Format
String
(ActiveAgency' st' (StateAgency st')
-> SingObjectDiffusion st' -> Word -> Int -> String)
-> ActiveAgency' st' (StateAgency st')
-> SingObjectDiffusion st'
-> Word
-> Int
-> String
forall a. Format String a -> a
formatToString Format
String
(ActiveAgency' st' (StateAgency st')
-> StateToken st' -> Word -> Int -> String)
Format
String
(ActiveAgency' st' (StateAgency st')
-> SingObjectDiffusion st' -> Word -> Int -> String)
forall (st' :: ObjectDiffusion objectId object) r.
Format r (ActiveAgency st' -> StateToken st' -> Word -> Int -> r)
fmterr (ActiveAgency' st' 'ClientAgency
ActiveAgency' st' (StateAgency st')
forall {ps} (st :: ps) (agency :: Agency).
IsActiveState st agency =>
ActiveAgency' st agency
activeAgency :: ActiveAgency st') StateToken st'
SingObjectDiffusion st'
stok Word
key Int
len)
fmterr :: forall (st' :: ObjectDiffusion objectId object) r.
F.Format r (ActiveAgency st' -> StateToken st' -> Word -> Int -> r)
fmterr :: forall (st' :: ObjectDiffusion objectId object) r.
Format r (ActiveAgency st' -> StateToken st' -> Word -> Int -> r)
fmterr = Format
(ActiveAgency' st' (StateAgency st')
-> SingObjectDiffusion st' -> Word -> Int -> r)
(ActiveAgency' st' (StateAgency st')
-> SingObjectDiffusion st' -> Word -> Int -> r)
"codecObjectDiffusion"
Format
(ActiveAgency' st' (StateAgency st')
-> SingObjectDiffusion st' -> Word -> Int -> r)
(ActiveAgency' st' (StateAgency st')
-> SingObjectDiffusion st' -> Word -> Int -> r)
-> Format
r
(ActiveAgency' st' (StateAgency st')
-> SingObjectDiffusion st' -> Word -> Int -> r)
-> Format
r
(ActiveAgency' st' (StateAgency st')
-> SingObjectDiffusion st' -> Word -> Int -> r)
forall r a r'. Format r a -> Format r' r -> Format r' a
%+ Format
(Word -> Int -> r)
(ActiveAgency' st' (StateAgency st')
-> SingObjectDiffusion st' -> Word -> Int -> r)
-> Format
(Word -> Int -> r)
(ActiveAgency' st' (StateAgency st')
-> SingObjectDiffusion st' -> Word -> Int -> r)
forall r a. Format r a -> Format r a
F.parenthesised (Format
(SingObjectDiffusion st' -> Word -> Int -> r)
(ActiveAgency' st' (StateAgency st')
-> SingObjectDiffusion st' -> Word -> Int -> r)
forall a r. Show a => Format r (a -> r)
F.shown Format
(SingObjectDiffusion st' -> Word -> Int -> r)
(ActiveAgency' st' (StateAgency st')
-> SingObjectDiffusion st' -> Word -> Int -> r)
-> Format
(Word -> Int -> r) (SingObjectDiffusion st' -> Word -> Int -> r)
-> Format
(Word -> Int -> r)
(ActiveAgency' st' (StateAgency st')
-> SingObjectDiffusion st' -> Word -> Int -> r)
forall r a r'. Format r a -> Format r' r -> Format r' a
F.% Format
(SingObjectDiffusion st' -> Word -> Int -> r)
(SingObjectDiffusion st' -> Word -> Int -> r)
"," Format
(SingObjectDiffusion st' -> Word -> Int -> r)
(SingObjectDiffusion st' -> Word -> Int -> r)
-> Format
(Word -> Int -> r) (SingObjectDiffusion st' -> Word -> Int -> r)
-> Format
(Word -> Int -> r) (SingObjectDiffusion st' -> Word -> Int -> r)
forall r a r'. Format r a -> Format r' r -> Format r' a
%+ Format
(Word -> Int -> r) (SingObjectDiffusion st' -> Word -> Int -> r)
forall a r. Show a => Format r (a -> r)
F.shown)
Format
(Word -> Int -> r)
(ActiveAgency' st' (StateAgency st')
-> SingObjectDiffusion st' -> Word -> Int -> r)
-> Format r (Word -> Int -> r)
-> Format
r
(ActiveAgency' st' (StateAgency st')
-> SingObjectDiffusion st' -> Word -> Int -> r)
forall r a r'. Format r a -> Format r' r -> Format r' a
%+ Format (Word -> Int -> r) (Word -> Int -> r)
"unexpected key"
Format (Word -> Int -> r) (Word -> Int -> r)
-> Format r (Word -> Int -> r) -> Format r (Word -> Int -> r)
forall r a r'. Format r a -> Format r' r -> Format r' a
%+ Format r (Word -> Int -> r) -> Format r (Word -> Int -> r)
forall r a. Format r a -> Format r a
F.parenthesised (Format (Int -> r) (Word -> Int -> r)
forall a r. Integral a => Format r (a -> r)
F.int Format (Int -> r) (Word -> Int -> r)
-> Format r (Int -> r) -> Format r (Word -> Int -> r)
forall r a r'. Format r a -> Format r' r -> Format r' a
F.% Format (Int -> r) (Int -> r)
"," Format (Int -> r) (Int -> r)
-> Format r (Int -> r) -> Format r (Int -> r)
forall r a r'. Format r a -> Format r' r -> Format r' a
%+ Format r (Int -> r)
forall a r. Integral a => Format r (a -> r)
F.int)
codecObjectDiffusionId
:: forall objectId object m.
Monad m
=> Codec
(ObjectDiffusion objectId object)
CodecFailure
m
(AnyMessage (ObjectDiffusion objectId object))
codecObjectDiffusionId :: forall objectId object (m :: * -> *).
Monad m =>
Codec
(ObjectDiffusion objectId object)
CodecFailure
m
(AnyMessage (ObjectDiffusion objectId object))
codecObjectDiffusionId = Codec {Message (ObjectDiffusion objectId object) st st'
-> AnyMessage (ObjectDiffusion objectId object)
forall (st :: ObjectDiffusion objectId object)
(st' :: ObjectDiffusion objectId object).
(ActiveState st, StateTokenI st) =>
Message (ObjectDiffusion objectId object) st st'
-> AnyMessage (ObjectDiffusion objectId object)
forall (st :: ObjectDiffusion objectId object)
(st' :: ObjectDiffusion objectId object).
(StateTokenI st, ActiveState st) =>
Message (ObjectDiffusion objectId object) st st'
-> AnyMessage (ObjectDiffusion objectId object)
encode :: forall (st :: ObjectDiffusion objectId object)
(st' :: ObjectDiffusion objectId object).
(ActiveState st, StateTokenI st) =>
Message (ObjectDiffusion objectId object) st st'
-> AnyMessage (ObjectDiffusion objectId object)
encode :: forall (st :: ObjectDiffusion objectId object)
(st' :: ObjectDiffusion objectId object).
(StateTokenI st, ActiveState st) =>
Message (ObjectDiffusion objectId object) st st'
-> AnyMessage (ObjectDiffusion objectId object)
encode, StateToken st
-> m (DecodeStep
(AnyMessage (ObjectDiffusion objectId object))
CodecFailure
m
(SomeMessage st))
forall (st :: ObjectDiffusion objectId object).
ActiveState st =>
StateToken st
-> m (DecodeStep
(AnyMessage (ObjectDiffusion objectId object))
CodecFailure
m
(SomeMessage st))
decode :: forall (st :: ObjectDiffusion objectId object).
ActiveState st =>
StateToken st
-> m (DecodeStep
(AnyMessage (ObjectDiffusion objectId object))
CodecFailure
m
(SomeMessage st))
decode :: forall (st :: ObjectDiffusion objectId object).
ActiveState st =>
StateToken st
-> m (DecodeStep
(AnyMessage (ObjectDiffusion objectId object))
CodecFailure
m
(SomeMessage st))
decode}
where
encode
:: forall st st'.
( ActiveState st
, StateTokenI st
)
=> Message (ObjectDiffusion objectId object) st st'
-> AnyMessage (ObjectDiffusion objectId object)
encode :: forall (st :: ObjectDiffusion objectId object)
(st' :: ObjectDiffusion objectId object).
(ActiveState st, StateTokenI st) =>
Message (ObjectDiffusion objectId object) st st'
-> AnyMessage (ObjectDiffusion objectId object)
encode = Message (ObjectDiffusion objectId object) st st'
-> AnyMessage (ObjectDiffusion objectId object)
forall ps (st :: ps) (st' :: ps).
(StateTokenI st, ActiveState st) =>
Message ps st st' -> AnyMessage ps
AnyMessage
decode
:: forall (st :: ObjectDiffusion objectId object).
ActiveState st
=> StateToken st
-> m (DecodeStep
(AnyMessage (ObjectDiffusion objectId object))
CodecFailure
m
(SomeMessage st)
)
decode :: forall (st :: ObjectDiffusion objectId object).
ActiveState st =>
StateToken st
-> m (DecodeStep
(AnyMessage (ObjectDiffusion objectId object))
CodecFailure
m
(SomeMessage st))
decode StateToken st
stok = DecodeStep
(AnyMessage (ObjectDiffusion objectId object))
CodecFailure
m
(SomeMessage st)
-> m (DecodeStep
(AnyMessage (ObjectDiffusion objectId object))
CodecFailure
m
(SomeMessage st))
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return (DecodeStep
(AnyMessage (ObjectDiffusion objectId object))
CodecFailure
m
(SomeMessage st)
-> m (DecodeStep
(AnyMessage (ObjectDiffusion objectId object))
CodecFailure
m
(SomeMessage st)))
-> DecodeStep
(AnyMessage (ObjectDiffusion objectId object))
CodecFailure
m
(SomeMessage st)
-> m (DecodeStep
(AnyMessage (ObjectDiffusion objectId object))
CodecFailure
m
(SomeMessage st))
forall a b. (a -> b) -> a -> b
$ (Maybe (AnyMessage (ObjectDiffusion objectId object))
-> m (DecodeStep
(AnyMessage (ObjectDiffusion objectId object))
CodecFailure
m
(SomeMessage st)))
-> DecodeStep
(AnyMessage (ObjectDiffusion objectId object))
CodecFailure
m
(SomeMessage st)
forall bytes failure (m :: * -> *) a.
(Maybe bytes -> m (DecodeStep bytes failure m a))
-> DecodeStep bytes failure m a
DecodePartial ((Maybe (AnyMessage (ObjectDiffusion objectId object))
-> m (DecodeStep
(AnyMessage (ObjectDiffusion objectId object))
CodecFailure
m
(SomeMessage st)))
-> DecodeStep
(AnyMessage (ObjectDiffusion objectId object))
CodecFailure
m
(SomeMessage st))
-> (Maybe (AnyMessage (ObjectDiffusion objectId object))
-> m (DecodeStep
(AnyMessage (ObjectDiffusion objectId object))
CodecFailure
m
(SomeMessage st)))
-> DecodeStep
(AnyMessage (ObjectDiffusion objectId object))
CodecFailure
m
(SomeMessage st)
forall a b. (a -> b) -> a -> b
$ \Maybe (AnyMessage (ObjectDiffusion objectId object))
bytes ->
DecodeStep
(AnyMessage (ObjectDiffusion objectId object))
CodecFailure
m
(SomeMessage st)
-> m (DecodeStep
(AnyMessage (ObjectDiffusion objectId object))
CodecFailure
m
(SomeMessage st))
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return (DecodeStep
(AnyMessage (ObjectDiffusion objectId object))
CodecFailure
m
(SomeMessage st)
-> m (DecodeStep
(AnyMessage (ObjectDiffusion objectId object))
CodecFailure
m
(SomeMessage st)))
-> DecodeStep
(AnyMessage (ObjectDiffusion objectId object))
CodecFailure
m
(SomeMessage st)
-> m (DecodeStep
(AnyMessage (ObjectDiffusion objectId object))
CodecFailure
m
(SomeMessage st))
forall a b. (a -> b) -> a -> b
$ case (StateToken st
SingObjectDiffusion st
stok, Maybe (AnyMessage (ObjectDiffusion objectId object))
bytes) of
(SingObjectDiffusion st
SingInit, Just (AnyMessage msg :: Message (ObjectDiffusion objectId object) st st'
msg@Message (ObjectDiffusion objectId object) st st'
R:MessageObjectDiffusionfromto objectId object st st'
MsgInit)) ->
SomeMessage st
-> Maybe (AnyMessage (ObjectDiffusion objectId object))
-> DecodeStep
(AnyMessage (ObjectDiffusion objectId object))
CodecFailure
m
(SomeMessage st)
forall bytes failure (m :: * -> *) a.
a -> Maybe bytes -> DecodeStep bytes failure m a
DecodeDone (Message (ObjectDiffusion objectId object) st st' -> SomeMessage st
forall ps (st :: ps) (st' :: ps).
(StateTokenI st, StateTokenI st', ActiveState st) =>
Message ps st st' -> SomeMessage st
SomeMessage Message (ObjectDiffusion objectId object) st st'
Message (ObjectDiffusion objectId object) st st'
msg) Maybe (AnyMessage (ObjectDiffusion objectId object))
forall a. Maybe a
Nothing
(SingObjectDiffusion st
SingIdle, Just (AnyMessage msg :: Message (ObjectDiffusion objectId object) st st'
msg@(MsgRequestObjectIds SingObjectIdsRequestKind kind
SingRequestObjectIdsBlocking NumObjectIdsAck
_ NumObjectIdsReq
_))) ->
SomeMessage st
-> Maybe (AnyMessage (ObjectDiffusion objectId object))
-> DecodeStep
(AnyMessage (ObjectDiffusion objectId object))
CodecFailure
m
(SomeMessage st)
forall bytes failure (m :: * -> *) a.
a -> Maybe bytes -> DecodeStep bytes failure m a
DecodeDone (Message (ObjectDiffusion objectId object) st st' -> SomeMessage st
forall ps (st :: ps) (st' :: ps).
(StateTokenI st, StateTokenI st', ActiveState st) =>
Message ps st st' -> SomeMessage st
SomeMessage Message (ObjectDiffusion objectId object) st st'
Message (ObjectDiffusion objectId object) st st'
msg) Maybe (AnyMessage (ObjectDiffusion objectId object))
forall a. Maybe a
Nothing
(SingObjectDiffusion st
SingIdle, Just (AnyMessage msg :: Message (ObjectDiffusion objectId object) st st'
msg@(MsgRequestObjectIds SingObjectIdsRequestKind kind
SingRequestObjectIdsNonBlocking NumObjectIdsAck
_ NumObjectIdsReq
_))) ->
SomeMessage st
-> Maybe (AnyMessage (ObjectDiffusion objectId object))
-> DecodeStep
(AnyMessage (ObjectDiffusion objectId object))
CodecFailure
m
(SomeMessage st)
forall bytes failure (m :: * -> *) a.
a -> Maybe bytes -> DecodeStep bytes failure m a
DecodeDone (Message (ObjectDiffusion objectId object) st st' -> SomeMessage st
forall ps (st :: ps) (st' :: ps).
(StateTokenI st, StateTokenI st', ActiveState st) =>
Message ps st st' -> SomeMessage st
SomeMessage Message (ObjectDiffusion objectId object) st st'
Message (ObjectDiffusion objectId object) st st'
msg) Maybe (AnyMessage (ObjectDiffusion objectId object))
forall a. Maybe a
Nothing
(SingObjectDiffusion st
SingIdle, Just (AnyMessage msg :: Message (ObjectDiffusion objectId object) st st'
msg@(MsgRequestObjects {}))) ->
SomeMessage st
-> Maybe (AnyMessage (ObjectDiffusion objectId object))
-> DecodeStep
(AnyMessage (ObjectDiffusion objectId object))
CodecFailure
m
(SomeMessage st)
forall bytes failure (m :: * -> *) a.
a -> Maybe bytes -> DecodeStep bytes failure m a
DecodeDone (Message (ObjectDiffusion objectId object) st st' -> SomeMessage st
forall ps (st :: ps) (st' :: ps).
(StateTokenI st, StateTokenI st', ActiveState st) =>
Message ps st st' -> SomeMessage st
SomeMessage Message (ObjectDiffusion objectId object) st st'
Message (ObjectDiffusion objectId object) st st'
msg) Maybe (AnyMessage (ObjectDiffusion objectId object))
forall a. Maybe a
Nothing
(SingObjectDiffusion st
SingObjects, Just (AnyMessage msg :: Message (ObjectDiffusion objectId object) st st'
msg@(MsgReplyObjects {}))) ->
SomeMessage st
-> Maybe (AnyMessage (ObjectDiffusion objectId object))
-> DecodeStep
(AnyMessage (ObjectDiffusion objectId object))
CodecFailure
m
(SomeMessage st)
forall bytes failure (m :: * -> *) a.
a -> Maybe bytes -> DecodeStep bytes failure m a
DecodeDone (Message (ObjectDiffusion objectId object) st st' -> SomeMessage st
forall ps (st :: ps) (st' :: ps).
(StateTokenI st, StateTokenI st', ActiveState st) =>
Message ps st st' -> SomeMessage st
SomeMessage Message (ObjectDiffusion objectId object) st st'
Message (ObjectDiffusion objectId object) st st'
msg) Maybe (AnyMessage (ObjectDiffusion objectId object))
forall a. Maybe a
Nothing
(SingObjectIds SingStObjectIdsKind kind
kind, Just (AnyMessage Message (ObjectDiffusion objectId object) st st'
msg)) -> Sing kind
-> (SingI kind =>
DecodeStep
(AnyMessage (ObjectDiffusion objectId object))
CodecFailure
m
(SomeMessage st))
-> DecodeStep
(AnyMessage (ObjectDiffusion objectId object))
CodecFailure
m
(SomeMessage st)
forall {k} (n :: k) r. Sing n -> (SingI n => r) -> r
withSingI Sing kind
SingStObjectIdsKind kind
kind ((SingI kind =>
DecodeStep
(AnyMessage (ObjectDiffusion objectId object))
CodecFailure
m
(SomeMessage st))
-> DecodeStep
(AnyMessage (ObjectDiffusion objectId object))
CodecFailure
m
(SomeMessage st))
-> (SingI kind =>
DecodeStep
(AnyMessage (ObjectDiffusion objectId object))
CodecFailure
m
(SomeMessage st))
-> DecodeStep
(AnyMessage (ObjectDiffusion objectId object))
CodecFailure
m
(SomeMessage st)
forall a b. (a -> b) -> a -> b
$
case (SingStObjectIdsKind kind
kind, Message (ObjectDiffusion objectId object) st st'
msg) of
(SingObjectIdsBlocking SingStObjectIdsPhase phase
_, MsgReplyObjectIds (BlockingReply NonEmpty objectId
objectIds)) ->
SomeMessage st
-> Maybe (AnyMessage (ObjectDiffusion objectId object))
-> DecodeStep
(AnyMessage (ObjectDiffusion objectId object))
CodecFailure
m
(SomeMessage st)
forall bytes failure (m :: * -> *) a.
a -> Maybe bytes -> DecodeStep bytes failure m a
DecodeDone
(Message (ObjectDiffusion objectId object) st 'StIdle
-> SomeMessage st
forall ps (st :: ps) (st' :: ps).
(StateTokenI st, StateTokenI st', ActiveState st) =>
Message ps st st' -> SomeMessage st
SomeMessage (ObjectIdsReplyList ('StObjectIdsBlocking phase) objectId
-> Message
(ObjectDiffusion objectId object)
('StObjectIds ('StObjectIdsBlocking phase))
'StIdle
forall (kind :: StObjectIdsKind) objectId object.
ObjectIdsReplyList kind objectId
-> Message
(ObjectDiffusion objectId object) ('StObjectIds kind) 'StIdle
MsgReplyObjectIds (NonEmpty objectId
-> ObjectIdsReplyList ('StObjectIdsBlocking phase) objectId
forall a (phase :: StObjectIdsPhase).
NonEmpty a -> ObjectIdsReplyList ('StObjectIdsBlocking phase) a
BlockingReply NonEmpty objectId
objectIds)))
Maybe (AnyMessage (ObjectDiffusion objectId object))
forall a. Maybe a
Nothing
(SingObjectIdsBlocking SingStObjectIdsPhase phase
SingCanAwait, Message (ObjectDiffusion objectId object) st st'
R:MessageObjectDiffusionfromto objectId object st st'
MsgAwaitReply) ->
SomeMessage st
-> Maybe (AnyMessage (ObjectDiffusion objectId object))
-> DecodeStep
(AnyMessage (ObjectDiffusion objectId object))
CodecFailure
m
(SomeMessage st)
forall bytes failure (m :: * -> *) a.
a -> Maybe bytes -> DecodeStep bytes failure m a
DecodeDone (Message
(ObjectDiffusion objectId object)
st
('StObjectIds ('StObjectIdsBlocking 'StMustReply))
-> SomeMessage st
forall ps (st :: ps) (st' :: ps).
(StateTokenI st, StateTokenI st', ActiveState st) =>
Message ps st st' -> SomeMessage st
SomeMessage Message
(ObjectDiffusion objectId object)
st
('StObjectIds ('StObjectIdsBlocking 'StMustReply))
Message
(ObjectDiffusion objectId object)
('StObjectIds ('StObjectIdsBlocking 'StCanAwait))
('StObjectIds ('StObjectIdsBlocking 'StMustReply))
forall objectId object.
Message
(ObjectDiffusion objectId object)
('StObjectIds ('StObjectIdsBlocking 'StCanAwait))
('StObjectIds ('StObjectIdsBlocking 'StMustReply))
MsgAwaitReply) Maybe (AnyMessage (ObjectDiffusion objectId object))
forall a. Maybe a
Nothing
(SingObjectIdsBlocking SingStObjectIdsPhase phase
SingMustReply, Message (ObjectDiffusion objectId object) st st'
R:MessageObjectDiffusionfromto objectId object st st'
MsgServerIdle) ->
SomeMessage st
-> Maybe (AnyMessage (ObjectDiffusion objectId object))
-> DecodeStep
(AnyMessage (ObjectDiffusion objectId object))
CodecFailure
m
(SomeMessage st)
forall bytes failure (m :: * -> *) a.
a -> Maybe bytes -> DecodeStep bytes failure m a
DecodeDone (Message (ObjectDiffusion objectId object) st 'StIdle
-> SomeMessage st
forall ps (st :: ps) (st' :: ps).
(StateTokenI st, StateTokenI st', ActiveState st) =>
Message ps st st' -> SomeMessage st
SomeMessage Message (ObjectDiffusion objectId object) st 'StIdle
Message
(ObjectDiffusion objectId object)
('StObjectIds ('StObjectIdsBlocking 'StMustReply))
'StIdle
forall objectId object.
Message
(ObjectDiffusion objectId object)
('StObjectIds ('StObjectIdsBlocking 'StMustReply))
'StIdle
MsgServerIdle) Maybe (AnyMessage (ObjectDiffusion objectId object))
forall a. Maybe a
Nothing
(SingStObjectIdsKind kind
SingObjectIdsNonBlocking, MsgReplyObjectIds (NonBlockingReply [objectId]
objectIds)) ->
SomeMessage st
-> Maybe (AnyMessage (ObjectDiffusion objectId object))
-> DecodeStep
(AnyMessage (ObjectDiffusion objectId object))
CodecFailure
m
(SomeMessage st)
forall bytes failure (m :: * -> *) a.
a -> Maybe bytes -> DecodeStep bytes failure m a
DecodeDone
(Message (ObjectDiffusion objectId object) st 'StIdle
-> SomeMessage st
forall ps (st :: ps) (st' :: ps).
(StateTokenI st, StateTokenI st', ActiveState st) =>
Message ps st st' -> SomeMessage st
SomeMessage (ObjectIdsReplyList 'StObjectIdsNonBlocking objectId
-> Message
(ObjectDiffusion objectId object)
('StObjectIds 'StObjectIdsNonBlocking)
'StIdle
forall (kind :: StObjectIdsKind) objectId object.
ObjectIdsReplyList kind objectId
-> Message
(ObjectDiffusion objectId object) ('StObjectIds kind) 'StIdle
MsgReplyObjectIds ([objectId] -> ObjectIdsReplyList 'StObjectIdsNonBlocking objectId
forall a. [a] -> ObjectIdsReplyList 'StObjectIdsNonBlocking a
NonBlockingReply [objectId]
objectIds)))
Maybe (AnyMessage (ObjectDiffusion objectId object))
forall a. Maybe a
Nothing
(SingStObjectIdsKind kind
_, Message (ObjectDiffusion objectId object) st st'
_) ->
CodecFailure
-> DecodeStep
(AnyMessage (ObjectDiffusion objectId object))
CodecFailure
m
(SomeMessage st)
forall bytes failure (m :: * -> *) a.
failure -> DecodeStep bytes failure m a
DecodeFail (CodecFailure
-> DecodeStep
(AnyMessage (ObjectDiffusion objectId object))
CodecFailure
m
(SomeMessage st))
-> CodecFailure
-> DecodeStep
(AnyMessage (ObjectDiffusion objectId object))
CodecFailure
m
(SomeMessage st)
forall a b. (a -> b) -> a -> b
$ String -> CodecFailure
CodecFailure String
"codecObjectDiffusionId: no matching message"
(SingObjectDiffusion st
SingIdle, Just (AnyMessage msg :: Message (ObjectDiffusion objectId object) st st'
msg@Message (ObjectDiffusion objectId object) st st'
R:MessageObjectDiffusionfromto objectId object st st'
MsgDone)) ->
SomeMessage st
-> Maybe (AnyMessage (ObjectDiffusion objectId object))
-> DecodeStep
(AnyMessage (ObjectDiffusion objectId object))
CodecFailure
m
(SomeMessage st)
forall bytes failure (m :: * -> *) a.
a -> Maybe bytes -> DecodeStep bytes failure m a
DecodeDone (Message (ObjectDiffusion objectId object) st st' -> SomeMessage st
forall ps (st :: ps) (st' :: ps).
(StateTokenI st, StateTokenI st', ActiveState st) =>
Message ps st st' -> SomeMessage st
SomeMessage Message (ObjectDiffusion objectId object) st st'
Message (ObjectDiffusion objectId object) st st'
msg) Maybe (AnyMessage (ObjectDiffusion objectId object))
forall a. Maybe a
Nothing
(SingObjectDiffusion st
SingDone, Maybe (AnyMessage (ObjectDiffusion objectId object))
_) ->
StateToken 'StDone -> forall a. a
forall ps (st :: ps).
(StateAgency st ~ 'NobodyAgency, ActiveState st) =>
StateToken st -> forall a. a
notActiveState StateToken st
StateToken 'StDone
stok
(SingObjectDiffusion st
_, Maybe (AnyMessage (ObjectDiffusion objectId object))
_) ->
CodecFailure
-> DecodeStep
(AnyMessage (ObjectDiffusion objectId object))
CodecFailure
m
(SomeMessage st)
forall bytes failure (m :: * -> *) a.
failure -> DecodeStep bytes failure m a
DecodeFail (CodecFailure
-> DecodeStep
(AnyMessage (ObjectDiffusion objectId object))
CodecFailure
m
(SomeMessage st))
-> CodecFailure
-> DecodeStep
(AnyMessage (ObjectDiffusion objectId object))
CodecFailure
m
(SomeMessage st)
forall a b. (a -> b) -> a -> b
$ String -> CodecFailure
CodecFailure String
"codecObjectDiffusionId: no matching message"