rename framing to framer

This commit is contained in:
Joel Wetzell
2025-12-07 10:42:51 -06:00
parent 0bd43ca0c3
commit 5e7ebd1bf1
6 changed files with 12 additions and 12 deletions

26
internal/framer/framer.go Normal file
View File

@@ -0,0 +1,26 @@
package framer
import (
"fmt"
)
type Framer interface {
Decode([]byte) [][]byte
Encode([]byte) []byte
Clear()
}
func GetFramer(framingType string) (Framer, error) {
switch framingType {
case "CR":
return NewByteSeparatorFramer([]byte{'\r'}), nil
case "LF":
return NewByteSeparatorFramer([]byte{'\n'}), nil
case "CRLF":
return NewByteSeparatorFramer([]byte{'\r', '\n'}), nil
case "SLIP":
return NewSlipFramer(), nil
default:
return nil, fmt.Errorf("unknown framing method: %s", framingType)
}
}