subscription

package
v0.2.13 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2025 License: Unlicense Imports: 6 Imported by: 0

Documentation

Overview

Package subscription is a set of helpers for managing nostr websocket subscription Ids, used with the REQ method to maintain an association between a REQ and resultant messages such as EVENT and CLOSED.

Index

Constants

View Source
const StdHRP = "su"
View Source
const StdLen = 14

Variables

This section is empty.

Functions

This section is empty.

Types

type Id

type Id struct {
	T []byte
}

func MustNew

func MustNew[V string | []byte](s V) *Id

MustNew is the same as NewId except it doesn't check if you feed it rubbish.

DO NOT USE WITHOUT CHECKING THE Id IS NOT NIL AND > 0 AND <= 64

func NewId

func NewId[V string | []byte](s V) (*Id, error)

NewId inspects a string and converts to Id if it is valid. Invalid means length == 0 or length > 64.

func NewStd

func NewStd() (t *Id)

NewStd creates a new standard subscription ID, which is a 14 byte long (92 bit) identifier, encoded using bech32.

func (*Id) IsValid

func (si *Id) IsValid() bool

IsValid returns true if the subscription id is between 1 and 64 characters. Invalid means too long or not present.

func (*Id) Marshal

func (si *Id) Marshal(dst []byte) (b []byte)

Marshal renders the raw bytes of a subscription.Id to raw byte string.

func (*Id) String

func (si *Id) String() string

func (*Id) Unmarshal

func (si *Id) Unmarshal(b []byte) (r []byte, err error)

Unmarshal a subscription.Id from raw bytes.

Jump to

Keyboard shortcuts

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