don't export module/processor/framer registrations

This commit is contained in:
Joel Wetzell
2026-05-26 17:27:35 -05:00
parent 0ff212742a
commit 80f8152dfb
77 changed files with 299 additions and 258 deletions
+5 -5
View File
@@ -10,15 +10,15 @@ type Framer interface {
func GetFramer(framingType string) Framer {
switch framingType {
case "CR":
return NewByteSeparatorFramer([]byte{'\r'})
return newByteSeparatorFramer([]byte{'\r'})
case "LF":
return NewByteSeparatorFramer([]byte{'\n'})
return newByteSeparatorFramer([]byte{'\n'})
case "CRLF":
return NewByteSeparatorFramer([]byte{'\r', '\n'})
return newByteSeparatorFramer([]byte{'\r', '\n'})
case "SLIP":
return NewSlipFramer()
return newSlipFramer()
case "RAW":
return NewRawFramer()
return newRawFramer()
default:
return nil
}
+7 -7
View File
@@ -1,23 +1,23 @@
package framer
type RawFramer struct{}
type rawFramer struct{}
func NewRawFramer() *RawFramer {
return &RawFramer{}
func newRawFramer() *rawFramer {
return &rawFramer{}
}
func (rf *RawFramer) Decode(data []byte) [][]byte {
func (rf *rawFramer) Decode(data []byte) [][]byte {
return [][]byte{data}
}
func (rf *RawFramer) Encode(data []byte) []byte {
func (rf *rawFramer) Encode(data []byte) []byte {
return data
}
func (rf *RawFramer) Clear() {
func (rf *rawFramer) Clear() {
// NOTE(jwetzell): no internal state to clear
}
func (rf *RawFramer) Buffer() []byte {
func (rf *rawFramer) Buffer() []byte {
return []byte{}
}
+7 -7
View File
@@ -4,16 +4,16 @@ import (
"bytes"
)
type ByteSeparatorFramer struct {
type byteSeparatorFramer struct {
buffer []byte
separator []byte
}
func NewByteSeparatorFramer(separator []byte) *ByteSeparatorFramer {
return &ByteSeparatorFramer{separator: separator, buffer: []byte{}}
func newByteSeparatorFramer(separator []byte) *byteSeparatorFramer {
return &byteSeparatorFramer{separator: separator, buffer: []byte{}}
}
func (bsf *ByteSeparatorFramer) Decode(data []byte) [][]byte {
func (bsf *byteSeparatorFramer) Decode(data []byte) [][]byte {
messages := [][]byte{}
bsf.buffer = append(bsf.buffer, data...)
@@ -28,14 +28,14 @@ func (bsf *ByteSeparatorFramer) Decode(data []byte) [][]byte {
return messages
}
func (bsf *ByteSeparatorFramer) Encode(data []byte) []byte {
func (bsf *byteSeparatorFramer) Encode(data []byte) []byte {
return append(data, bsf.separator...)
}
func (bsf *ByteSeparatorFramer) Clear() {
func (bsf *byteSeparatorFramer) Clear() {
bsf.buffer = []byte{}
}
func (bsf *ByteSeparatorFramer) Buffer() []byte {
func (bsf *byteSeparatorFramer) Buffer() []byte {
return bsf.buffer
}
+7 -7
View File
@@ -1,14 +1,14 @@
package framer
type SlipFramer struct {
type slipFramer struct {
buffer []byte
}
func NewSlipFramer() *SlipFramer {
return &SlipFramer{buffer: []byte{}}
func newSlipFramer() *slipFramer {
return &slipFramer{buffer: []byte{}}
}
func (sf *SlipFramer) Decode(data []byte) [][]byte {
func (sf *slipFramer) Decode(data []byte) [][]byte {
messages := [][]byte{}
END := byte(0xc0)
@@ -49,7 +49,7 @@ func (sf *SlipFramer) Decode(data []byte) [][]byte {
return messages
}
func (sf *SlipFramer) Encode(data []byte) []byte {
func (sf *slipFramer) Encode(data []byte) []byte {
END := byte(0xc0)
ESC := byte(0xdb)
ESC_END := byte(0xdc)
@@ -72,10 +72,10 @@ func (sf *SlipFramer) Encode(data []byte) []byte {
return encodedBytes
}
func (sf *SlipFramer) Clear() {
func (sf *slipFramer) Clear() {
sf.buffer = []byte{}
}
func (sf *SlipFramer) Buffer() []byte {
func (sf *slipFramer) Buffer() []byte {
return sf.buffer
}