sys

package
v0.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 4, 2022 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package sys works around the shortcomings of gotrix/event.

Index

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 Parse

func Parse(b []byte) event.Event

Parse wraps around event.Parse.

func ParseAll

func ParseAll(raws []event.RawEvent) []event.Event

ParseAll parses the given list of raw events into a new list of events.

func ParseAllRoom

func ParseAllRoom(raws []event.RawEvent, rID matrix.RoomID) []event.Event

ParseAllRoom parses the given list of raw events into a new list of events.

func ParseAllTimeline

func ParseAllTimeline(raws []event.RawEvent, rID matrix.RoomID) []event.RoomEvent

ParseAllTimeline parses the given list of raw events into a new list of room events.

func ParseAs

func ParseAs(b []byte, typ event.Type) (event.Event, error)

ParseAs returns a nil event if the returned event is erroneous or doesn't match the given type.

func ParseRoom

func ParseRoom(b []byte, rID matrix.RoomID) event.Event

ParseRoom wraps around event.Parse.

func ParseTimeline

func ParseTimeline(b []byte, rID matrix.RoomID) event.RoomEvent

ParseTimeline wraps around event.Parse. TODO document.

func ParseUserEventContent

func ParseUserEventContent(typ event.Type, content json.RawMessage) (event.Event, error)

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) Error

func (ev ErroneousEvent) Error() string

Error implements error.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL