module Network.TLS.Measurement
( Measurement(..)
, newMeasurement
, addBytesReceived
, addBytesSent
, resetBytesCounters
, incrementNbHandshakes
) where
import Network.TLS.Imports
data Measurement = Measurement
{ nbHandshakes :: !Word32
, bytesReceived :: !Word32
, bytesSent :: !Word32
} deriving (Show,Eq)
newMeasurement :: Measurement
newMeasurement = Measurement
{ nbHandshakes = 0
, bytesReceived = 0
, bytesSent = 0
}
addBytesReceived :: Int -> Measurement -> Measurement
addBytesReceived sz measure =
measure { bytesReceived = bytesReceived measure + fromIntegral sz }
addBytesSent :: Int -> Measurement -> Measurement
addBytesSent sz measure =
measure { bytesSent = bytesSent measure + fromIntegral sz }
resetBytesCounters :: Measurement -> Measurement
resetBytesCounters measure = measure { bytesReceived = 0, bytesSent = 0 }
incrementNbHandshakes :: Measurement -> Measurement
incrementNbHandshakes measure =
measure { nbHandshakes = nbHandshakes measure + 1 }