tractor.dev/toolkit-go@v0.0.0-20241010005851-214d91207d07/duplex/codec/cbor.go (about)

     1  package codec
     2  
     3  import (
     4  	"io"
     5  
     6  	"github.com/fxamacker/cbor/v2"
     7  )
     8  
     9  // CBORCodec provides a codec API for a CBOR encoder and decoder.
    10  type CBORCodec struct{}
    11  
    12  // Encoder returns a CBOR encoder
    13  func (c CBORCodec) Encoder(w io.Writer) Encoder {
    14  	return cbor.NewEncoder(w)
    15  }
    16  
    17  // Decoder returns a CBOR decoder
    18  func (c CBORCodec) Decoder(r io.Reader) Decoder {
    19  	return cbor.NewDecoder(r)
    20  }