MCPcopy Create free account
hub / github.com/divan/txqr / Validate

Method Validate

decode.go:83–94  ·  view source on GitHub ↗

Validate checks if a given chunk of data is a valid txqr protocol packet.

(chunk string)

Source from the content-addressed store, hash-verified

81
82// Validate checks if a given chunk of data is a valid txqr protocol packet.
83func (d *Decoder) Validate(chunk string) error {
84 if chunk == "" || len(chunk) < 4 {
85 return fmt.Errorf("invalid frame: \"%s\"", chunk)
86 }
87
88 idx := strings.IndexByte(chunk, '|')
89 if idx == -1 {
90 return fmt.Errorf("invalid frame: \"%s\"", chunk)
91 }
92
93 return nil
94}
95
96// Data returns decoded data.
97func (d *Decoder) Data() string {

Callers 1

DecodeMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected