vyrn

std/codecs

7 exports, from std/codecs.vyrn.

Hex, base64 and percent encoding over UTF-8 bytes. These are the hexEncode, hexDecode, base64Encode, base64Decode, urlEncode and urlDecode builtins on every engine; tests/codecs.rs pins their output.

A decoder whose bytes contain 0x00 returns None: a Vyrn String cannot hold a NUL, and stringFromBytes enforces it.

Dependencies

The import graph shows the whole library.

Imports
Imported by
fn hexDecode(s: String) -> Option<String>

Hex text back to a String; None on an odd length, a non-hex digit, or bytes that are not valid UTF-8. Reads either case.

fn base64Decode(s: String) -> Option<String>

Base64 text back to a String; None unless the length is a multiple of four, every digit is in the alphabet, padding is = or == in the final group only, and the bytes are valid UTF-8.

fn urlDecode(s: String) -> Option<String>

Percent-encoded text back to a String; None on a truncated or non-hex escape, or bytes that are not valid UTF-8. A raw space or + decodes to itself.

Tests

4 test blocks in std/codecs.vyrn. CI runs all of them.

Test names
  • hex is two lowercase digits a byte, and reads either case back
  • base64 pads at all three residues, and refuses misplaced padding
  • percent-encoding keeps the unreserved set and nothing else
  • a decoded NUL is refused, because a Vyrn String cannot hold one

Examples

2 programs in examples/ import this module. Each runs as WebAssembly and as a native binary.