add RAW framer for passthrough

This commit is contained in:
Joel Wetzell
2025-12-08 19:31:42 -06:00
parent 202d1aea1f
commit a85b0e64e0
2 changed files with 25 additions and 0 deletions

View File

@@ -21,6 +21,8 @@ func GetFramer(framingType string) (Framer, error) {
return NewByteSeparatorFramer([]byte{'\r', '\n'}), nil return NewByteSeparatorFramer([]byte{'\r', '\n'}), nil
case "SLIP": case "SLIP":
return NewSlipFramer(), nil return NewSlipFramer(), nil
case "RAW":
return NewRawFramer(), nil
default: default:
return nil, fmt.Errorf("unknown framing method: %s", framingType) return nil, fmt.Errorf("unknown framing method: %s", framingType)
} }

23
internal/framer/raw.go Normal file
View File

@@ -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{}
}