text

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: Unlicense Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendBackticks

func AppendBackticks(dst, src by, ac AppendBytesClosure) by

func AppendBinary

func AppendBinary(dst, src by) (b by)

AppendBinary is a straight append with length prefix.

func AppendBinaryFromHex

func AppendBinaryFromHex(dst, src by, unquote bo) (b by,
	err er)

func AppendBrace

func AppendBrace(dst, src by, ac AppendBytesClosure) by

func AppendBracket

func AppendBracket(dst, src by, ac AppendBytesClosure) by

func AppendHexFromBinary

func AppendHexFromBinary(dst, src by, quote bo) (b by)

func AppendList

func AppendList(dst by, src []by, separator byte,
	ac AppendBytesClosure) by

func AppendParenthesis

func AppendParenthesis(dst, src by, ac AppendBytesClosure) by

func AppendQuote

func AppendQuote(dst, src by, ac AppendBytesClosure) by

func AppendSingleQuote

func AppendSingleQuote(dst, src by, ac AppendBytesClosure) by

func Comma

func Comma(b by) (rem by, err er)

func ExtractBinary

func ExtractBinary(b by) (str, rem by, err er)

ExtractBinary decodes the data based on the length prefix and returns a the the remaining data from the provided slice.

func False

func False() by

func JSONKey

func JSONKey(dst, k by) (b by)

JSONKey generates the JSON format for an object key and terminates with the semicolon.

func MarshalBool

func MarshalBool(src by, truth bo) by

func MarshalHexArray

func MarshalHexArray(dst by, ha []by) (b by)

func MarshalKindsArray

func MarshalKindsArray(dst by, ka *kinds.T) (b by)

func Noop

func Noop(dst, src by) by

func NostrEscape

func NostrEscape(dst, src by) by

NostrEscape for JSON encoding according to RFC8259.

This is the efficient implementation based on the NIP-01 specification:

To prevent implementation differences from creating a different event ID for the same event, the following rules MUST be followed while serializing:

No whitespace, line breaks or other unnecessary formatting should be included
in the output JSON. No characters except the following should be escaped, and
instead should be included verbatim:

- A line break, 0x0A, as \n
- A double quote, 0x22, as \"
- A backslash, 0x5C, as \\
- A carriage return, 0x0D, as \r
- A tab character, 0x09, as \t
- A backspace, 0x08, as \b
- A form feed, 0x0C, as \f

UTF-8 should be used for encoding.

func NostrUnescape

func NostrUnescape(dst by) (b by)

NostrUnescape reverses the operation of NostrEscape except instead of appending it to the provided slice, it rewrites it, eliminating a memory copy. Keep in mind that the original JSON will be mangled by this operation, but the resultant slices will cost zero allocations.

func Quote

func Quote(dst, src by) by

func True

func True() by

func UnmarshalBool

func UnmarshalBool(src by) (rem by, truth bo, err er)

func UnmarshalHex

func UnmarshalHex(b by) (h by, rem by, err er)

UnmarshalHex takes a byte string that should contain a quoted hexadecimal encoded value, decodes it in-place using a SIMD hex codec and returns the decoded truncated bytes (the other half will be as it was but no allocation is required).

func UnmarshalHexArray

func UnmarshalHexArray(b by, size no) (t []by, rem by, err er)

UnmarshalHexArray unpacks a JSON array containing strings with hexadecimal, and checks all values have the specified byte size..

func UnmarshalKindsArray

func UnmarshalKindsArray(b by) (k *kinds.T, rem by, err er)

func UnmarshalQuoted

func UnmarshalQuoted(b by) (content, rem by, err er)

UnmarshalQuoted performs an in-place unquoting of NIP-01 quoted byte string.

func UnmarshalStringArray

func UnmarshalStringArray(b by) (t []by, rem by, err er)

UnmarshalStringArray unpacks a JSON array containing strings.

func Unquote

func Unquote(b by) by

Types

type AppendBytesClosure

type AppendBytesClosure func(dst, src by) by

type AppendClosure

type AppendClosure func(dst by) by

Jump to

Keyboard shortcuts

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