Validate checks if a given chunk of data is a valid txqr protocol packet.
(chunk string)
| 81 | |
| 82 | // Validate checks if a given chunk of data is a valid txqr protocol packet. |
| 83 | func (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. |
| 97 | func (d *Decoder) Data() string { |