MCPcopy Create free account
hub / github.com/blues/note / binAppendString

Method binAppendString

lib/bulk.go:1658–1683  ·  view source on GitHub ↗
(ctx context.Context, p string)

Source from the content-addressed store, hash-verified

1656}
1657
1658func (tmplContext *BulkTemplateContext) binAppendString(ctx context.Context, p string) (err error) {
1659 if debugEncoding {
1660 logDebug(ctx, "append %d STRING = %s", tmplContext.binDepth, p)
1661 }
1662 actualLen := uint32(len(p))
1663 if tmplContext.NoteFormat == BulkNoteFormatFlexNano {
1664 if actualLen > 255 {
1665 err = fmt.Errorf("compact mode only supports strings up to 255 bytes")
1666 } else {
1667 err = tmplContext.binAppendUint8(ctx, uint8(actualLen))
1668 if err == nil {
1669 err = tmplContext.binAppendUint8s(ctx, []uint8(p), actualLen)
1670 }
1671 }
1672 } else {
1673 if actualLen > 65535 {
1674 err = fmt.Errorf("strings must be smaller than up to 65535 bytes")
1675 } else {
1676 err = tmplContext.binAppendUint16(ctx, uint16(actualLen))
1677 if err == nil {
1678 err = tmplContext.binAppendUint8s(ctx, []uint8(p), actualLen)
1679 }
1680 }
1681 }
1682 return err
1683}
1684
1685func (tmplContext *BulkTemplateContext) binAppendReal16(ctx context.Context, number float32) (err error) {
1686 if debugEncoding {

Callers 1

processTemplateValueMethod · 0.95

Calls 4

binAppendUint8Method · 0.95
binAppendUint8sMethod · 0.95
binAppendUint16Method · 0.95
logDebugFunction · 0.85

Tested by

no test coverage detected