hex

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package hex is the "encoding/hex" host module. See std/encoding/register.go for why base64's nine siblings each get their own leaf package instead of living in std's flat root, and how this directory's Module reaches the rest of magus without std importing back down to collect it.

Index

Constants

This section is empty.

Variables

View Source
var Module = std.Module{
	Name: "hex",
	WASM: true,
	Path: "encoding/hex",
	Doc:  "Hex text codec.",
	Methods: []std.Method{
		{
			Name:    "encode",
			Doc:     "Encode data as lowercase hex.",
			Args:    []std.Arg{{Name: "data", Type: std.TypeString}},
			Returns: []std.Ret{{Type: std.TypeString}},
			Impl:    HexEncode,
		},
		{
			Name:    "decode",
			Doc:     "Decode a hex string; errors on malformed input.",
			Args:    []std.Arg{{Name: "s", Type: std.TypeString}},
			Returns: []std.Ret{{Type: std.TypeString}},
			Raises:  true,
			Impl:    HexDecode,
		},
	},
}

Module is the "encoding/hex" host module. Buzz strings carry a `.hex()` method already; this is the decode half, which the language has no form of, plus the encode half so a caller reaches both through one import rather than switching between a string method and a module.

Functions

func HexDecode

func HexDecode(_ context.Context, s string) (string, error)

HexDecode decodes a hex string.

func HexEncode

func HexEncode(_ context.Context, data string) (string, error)

HexEncode encodes data as lowercase hex.

func Modules

func Modules() []std.Module

Modules returns this directory's contribution to the encoding module set. See std/encoding/register.go: it aggregates every leaf's Modules() into one slice, which is how a module here reaches std.All()'s callers without std importing this package to collect it.

Types

This section is empty.

Jump to

Keyboard shortcuts

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