Documentation ¶
Index ¶
- func UnmarshalHex(b B) (h B, rem B, err error)
- func UnmarshalHexArray(b B, size int) (t []B, rem B, err error)
- type AppendBytesClosure
- type AppendClosure
- type B
- func AppendBackticks(dst, src B, ac AppendBytesClosure) B
- func AppendBinary(dst, src B) (b B)
- func AppendBinaryFromHex(dst, src B, unquote bool) (b B, err error)
- func AppendBrace(dst, src B, ac AppendBytesClosure) B
- func AppendBracket(dst, src B, ac AppendBytesClosure) B
- func AppendHexFromBinary(dst, src B, quote bool) (b B)
- func AppendList(dst B, src []B, separator byte, ac AppendBytesClosure) B
- func AppendParenthesis(dst, src B, ac AppendBytesClosure) B
- func AppendQuote(dst, src B, ac AppendBytesClosure) B
- func AppendSingleQuote(dst, src B, ac AppendBytesClosure) B
- func Comma(b B) (rem B, err error)
- func ExtractBinary(b B) (str, rem B, err error)
- func False() B
- func JSONKey(dst, k B) (b B)
- func MarshalBool(src B, truth bool) B
- func MarshalHexArray(dst B, ha []B) (b B)
- func MarshalKindsArray(dst B, ka *kinds.T) (b B)
- func Noop(dst, src B) B
- func NostrEscape(dst, src B) B
- func NostrUnescape(dst B) (b B)
- func Quote(dst, src B) B
- func True() B
- func UnmarshalBool(src B) (rem B, truth bool, err error)
- func UnmarshalKindsArray(b B) (k *kinds.T, rem B, err error)
- func UnmarshalQuoted(b B) (content, rem B, err error)
- func Unquote(b B) B
- type E
- type N
- type S
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func UnmarshalHex ¶
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).
Types ¶
type AppendBytesClosure ¶
type AppendClosure ¶
type B ¶
type B = []byte
func AppendBackticks ¶
func AppendBackticks(dst, src B, ac AppendBytesClosure) B
func AppendBinary ¶
AppendBinary is a straight append with length prefix.
func AppendBrace ¶
func AppendBrace(dst, src B, ac AppendBytesClosure) B
func AppendBracket ¶
func AppendBracket(dst, src B, ac AppendBytesClosure) B
func AppendHexFromBinary ¶
func AppendList ¶
func AppendList(dst B, src []B, separator byte, ac AppendBytesClosure) B
func AppendParenthesis ¶
func AppendParenthesis(dst, src B, ac AppendBytesClosure) B
func AppendQuote ¶
func AppendQuote(dst, src B, ac AppendBytesClosure) B
func AppendSingleQuote ¶
func AppendSingleQuote(dst, src B, ac AppendBytesClosure) B
func ExtractBinary ¶
ExtractBinary decodes the data based on the length prefix and returns a the the remaining data from the provided slice.
func JSONKey ¶
JSONKey generates the JSON format for an object key and terminates with the semicolon.
func MarshalBool ¶
func MarshalHexArray ¶
func NostrEscape ¶
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 ¶
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 UnmarshalQuoted ¶
UnmarshalQuoted performs an in-place unquoting of NIP-01 quoted byte string.