github.com/storacha/go-ucanto@v0.7.2/transport/codec.go (about)

     1  package transport
     2  
     3  import (
     4  	"github.com/storacha/go-ucanto/core/message"
     5  )
     6  
     7  type RequestEncoder interface {
     8  	Encode(message message.AgentMessage) (HTTPRequest, error)
     9  }
    10  
    11  type RequestDecoder interface {
    12  	Decode(request HTTPRequest) (message.AgentMessage, error)
    13  }
    14  
    15  type ResponseEncoder interface {
    16  	Encode(message message.AgentMessage) (HTTPResponse, error)
    17  }
    18  
    19  type ResponseDecoder interface {
    20  	Decode(response HTTPResponse) (message.AgentMessage, error)
    21  }
    22  
    23  type OutboundCodec interface {
    24  	RequestEncoder
    25  	ResponseDecoder
    26  }
    27  
    28  type InboundAcceptCodec interface {
    29  	// Decoder will be used by a server to decode HTTP Request into an invocation
    30  	// `Batch` that will be executed using a `service`.
    31  	Decoder() RequestDecoder
    32  	// Encoder will be used to encode batch of invocation results into an HTTP
    33  	// response that will be sent back to the client that initiated the request.
    34  	Encoder() ResponseEncoder
    35  }
    36  
    37  type InboundCodec interface {
    38  	Accept(request HTTPRequest) (InboundAcceptCodec, HTTPError)
    39  }