Documentation ¶
Overview ¶
Package sys works around the shortcomings of gotrix/event.
Index ¶
- func MarshalUserEvent(typ event.Type, content json.RawMessage) []byte
- func Parse(b []byte) event.Event
- func ParseAll(raws []event.RawEvent) []event.Event
- func ParseAllRoom(raws []event.RawEvent, rID matrix.RoomID) []event.Event
- func ParseAllTimeline(raws []event.RawEvent, rID matrix.RoomID) []event.RoomEvent
- func ParseAs(b []byte, typ event.Type) (event.Event, error)
- func ParseRoom(b []byte, rID matrix.RoomID) event.Event
- func ParseTimeline(b []byte, rID matrix.RoomID) event.RoomEvent
- func ParseUserEventContent(typ event.Type, content json.RawMessage) (event.Event, error)
- type ErroneousEvent
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MarshalUserEvent ¶
func MarshalUserEvent(typ event.Type, content json.RawMessage) []byte
MarshalUserEvent is used for user events only. content must be valid JSON.
func ParseAllRoom ¶
ParseAllRoom parses the given list of raw events into a new list of events.
func ParseAllTimeline ¶
ParseAllTimeline parses the given list of raw events into a new list of room events.
func ParseAs ¶
ParseAs returns a nil event if the returned event is erroneous or doesn't match the given type.
func ParseTimeline ¶
ParseTimeline wraps around event.Parse. TODO document.
func ParseUserEventContent ¶
ParseUserEventContent is used for user events only.
Types ¶
type ErroneousEvent ¶
type ErroneousEvent struct { event.RoomEventInfo `json:"-"` // may be empty Err error }
ErroneousEvent is a pseudoevent returned by Parse to indicate events that cannot be parsed, probably because it's not known.
func (ErroneousEvent) IsRoomEvent ¶
func (ev ErroneousEvent) IsRoomEvent() bool
IsRoomEvent returns true if the erroneous event is a room event.
func (ErroneousEvent) String ¶
func (ev ErroneousEvent) String() string
String returns the event name or a placeholder.