diff --git a/internal/framer/framer.go b/internal/framer/framer.go index 91db58b..4bb36d0 100644 --- a/internal/framer/framer.go +++ b/internal/framer/framer.go @@ -21,6 +21,8 @@ func GetFramer(framingType string) (Framer, error) { return NewByteSeparatorFramer([]byte{'\r', '\n'}), nil case "SLIP": return NewSlipFramer(), nil + case "RAW": + return NewRawFramer(), nil default: return nil, fmt.Errorf("unknown framing method: %s", framingType) } diff --git a/internal/framer/raw.go b/internal/framer/raw.go new file mode 100644 index 0000000..6c42974 --- /dev/null +++ b/internal/framer/raw.go @@ -0,0 +1,23 @@ +package framer + +type RawFramer struct{} + +func NewRawFramer() *RawFramer { + return &RawFramer{} +} + +func (rf *RawFramer) Decode(data []byte) [][]byte { + return [][]byte{data} +} + +func (rf *RawFramer) Encode(data []byte) []byte { + return data +} + +func (rf *RawFramer) Clear() { + // NOTE(jwetzell): no internal state to clear +} + +func (rf *RawFramer) Buffer() []byte { + return []byte{} +}