mirror of
https://github.com/jwetzell/showbridge-go.git
synced 2026-04-26 21:05:30 +00:00
add RAW framer for passthrough
This commit is contained in:
@@ -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
23
internal/framer/raw.go
Normal 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{}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user