<commit_before>{-|
Module: Capnp.Rpc.Transport
Description: Support for exchanging messages with remote vats.

This module provides a 'Transport' type, which provides operations
used to transmit messages between vats in the RPC protocol.
-}
module Capnp.Rpc.Transport
    ( Transport(..)
    , handleTransport
    , socketTransport
    , tracingTransport
    ) where

import Network.Socket (Socket)
import System.IO      (Handle)

import Capnp.Bits       (WordCount)
import Capnp.Convert    (msgToValue)
import Capnp.IO         (hGetMsg, hPutMsg, sGetMsg, sPutMsg)
import Capnp.Message    (ConstMsg)
import Text.Show.Pretty (ppShow)

import qualified Capnp.Gen.Capnp.Rpc.Pure as R

-- | A @'Transport'@ handles transmitting RPC messages.
data Transport = Transport
    { sendMsg :: ConstMsg -> IO ()
    -- ^ Send a message
    , recvMsg :: IO ConstMsg
    -- ^ Receive a message
    }

-- | @'handleTransport' handle limit@ is a transport which reads and writes<commit_msg>Port Rpc.Transport<commit_after>{-|
Module: Capnp.Rpc.Transport
Description: Support for exchanging messages with remote vats.

This module provides a 'Transport' type, which provides operations
used to transmit messages between vats in the RPC protocol.
-}
{-# LANGUAGE DataKinds #-}
module Capnp.Rpc.Transport
    ( Transport(..)
    , handleTransport
    , socketTransport
    , tracingTransport
    ) where

import Network.Socket (Socket)
import System.IO      (Handle)

import Capnp.Bits       (WordCount)
import Capnp.Convert    (msgToValue)
import Capnp.IO         (hGetMsg, hPutMsg, sGetMsg, sPutMsg)
import Capnp.Message    (Message, Mutability(Const))
import Text.Show.Pretty (ppShow)

import qualified Capnp.Gen.Capnp.Rpc.Pure as R

-- | A @'Transport'@ handles transmitting RPC messages.
data Transport = Transport
    { sendMsg :: Message 'Const -> IO ()
    -- ^ Send a message
    , recvMsg :: IO (Message 'Const)
    -- ^ Receive a message
    }

-- | @'handleTransport' handle limit@ is a transport which reads and writes
{'fraction_non_alphanumeric': 0.09642147117296222, 'fraction_numerical': 0.0, 'mean_word_length': 3.433920704845815, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1044807', 'n_tokens_mistral': 600, 'n_tokens_neox': 593, 'n_words': 199}