do not make the simd stuff a requirement for Envelope.

This commit is contained in:
fiatjaf 2025-02-25 18:23:38 -03:00
parent 201abf231b
commit be2fe4a019

View File

@ -43,7 +43,7 @@ func ParseMessageSIMD(message []byte, reuse *simdjson.ParsedJson) (Envelope, err
iter.Advance() iter.Advance()
label, _ := iter.StringBytes() label, _ := iter.StringBytes()
var v Envelope var v EnvelopeSIMD
switch { switch {
case bytes.Equal(label, labelEvent): case bytes.Equal(label, labelEvent):
@ -117,12 +117,16 @@ func ParseMessage(message []byte) Envelope {
type Envelope interface { type Envelope interface {
Label() string Label() string
UnmarshalSIMD(simdjson.Iter) error
UnmarshalJSON([]byte) error UnmarshalJSON([]byte) error
MarshalJSON() ([]byte, error) MarshalJSON() ([]byte, error)
String() string String() string
} }
type EnvelopeSIMD interface {
Envelope
UnmarshalSIMD(simdjson.Iter) error
}
var ( var (
_ Envelope = (*EventEnvelope)(nil) _ Envelope = (*EventEnvelope)(nil)
_ Envelope = (*ReqEnvelope)(nil) _ Envelope = (*ReqEnvelope)(nil)