-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Library to control network protocols
--
-- Common parts to control network protocols
@package network-control
@version 0.0.2
-- | Common parts to control network protocols.
module Network.Control
-- | Default max streams. (64)
defaultMaxStreams :: Int
-- | Default max data of a stream. (256K bytes)
defaultMaxStreamData :: Int
-- | Default max data of a connection. (1M bytes)
defaultMaxData :: Int
-- | Flow for sending
data TxFlow
TxFlow :: Int -> Int -> TxFlow
[txfSent] :: TxFlow -> Int
[txfLimit] :: TxFlow -> Int
-- | Creating TX flow with an initial window size.
newTxFlow :: WindowSize -> TxFlow
-- | txfLimit - txfSent.
txWindowSize :: TxFlow -> WindowSize
-- | Window size.
type WindowSize = Int
-- | Flow for receiving
data RxFlow
RxFlow :: WindowSize -> Int -> Int -> Int -> RxFlow
[rxfWindow] :: RxFlow -> WindowSize
[rxfConsumed] :: RxFlow -> Int
[rxfReceived] :: RxFlow -> Int
[rxfLimit] :: RxFlow -> Int
-- | Creating RX flow with an initial window size.
newRxFlow :: WindowSize -> RxFlow
-- | The representation of window size update.
data FlowControlType
-- | HTTP/2 style
FCTWindowUpdate :: FlowControlType
-- | QUIC style
FCTMaxData :: FlowControlType
-- | When an application consumed received data, this function should be
-- called to update rxfConsumed. If the window size is less than
-- the half of the initial window. the representation of window size
-- update is returned.
maybeOpenRxWindow :: Int -> FlowControlType -> RxFlow -> (RxFlow, Maybe Int)
-- | Checking if received data is acceptable against the current window.
checkRxLimit :: Int -> RxFlow -> (RxFlow, Bool)
-- | Sized cache based on least recently used.
data LRUCache k v
-- | Empty LRUCache.
empty :: Int -> LRUCache k v
-- | Inserting.
insert :: Ord k => k -> v -> LRUCache k v -> LRUCache k v
-- | Deleting.
delete :: Ord k => k -> LRUCache k v -> LRUCache k v
-- | Looking up.
lookup :: Ord k => k -> LRUCache k v -> Maybe v
-- | Type for rating.
data Rate
-- | Creating a new Rate.
newRate :: IO Rate
-- | Getting the current rate. If one or more seconds have passed since the
-- previous call, the counter is re-initialized with 1 and it is
-- returned. Otherwise, incremented counter number is returned.
getRate :: Rate -> IO Int
-- | Getting the current rate. If one or more seconds have passed since the
-- previous call, the counter is re-initialized with the second argument
-- and it is returned. Otherwise, increased counter number is returned.
addRate :: Rate -> Int -> IO Int