Creates a schema for string values.
Strings are encoded as UTF-8 with a variable-length size prefix. The wire format encodes character count in bytes using a tagged varint: 7 bits for lengths 0-127, or 4 bytes little-endian for larger strings.
A Relish schema for string values
import { RString, createCodec } from '@grounds/schema';const codec = createCodec(RString());codec.encode('hello').match( (bytes) => console.log('String encoded:', bytes), (error) => console.error(error)); Copy
import { RString, createCodec } from '@grounds/schema';const codec = createCodec(RString());codec.encode('hello').match( (bytes) => console.log('String encoded:', bytes), (error) => console.error(error));
Creates a schema for string values.
Strings are encoded as UTF-8 with a variable-length size prefix. The wire format encodes character count in bytes using a tagged varint: 7 bits for lengths 0-127, or 4 bytes little-endian for larger strings.