Skip to content

refactor(#57): rename utils→b64, split into int/binary/charset, + no_std stream fix#60

Merged
joeldsouzax merged 4 commits into
mainfrom
refactor/57-b64-module
Jul 2, 2026
Merged

refactor(#57): rename utils→b64, split into int/binary/charset, + no_std stream fix#60
joeldsouzax merged 4 commits into
mainfrom
refactor/57-b64-module

Conversation

@joeldsouzax

Copy link
Copy Markdown
Contributor

Phases 1a–1b of the module/naming restructure (#57), plus a folded-in no_std CI fix. Behaviour-preserving throughout — gate green including keripy vectors, cesr-wasm, and cesr-nostd.

What changed

Phase 1a — utilsb64 (9eb3b96): the utils module was a non-name for the CESR Base64 codec. Renamed module + cargo feature utilsb64, and killed the utils::utils module-inception (→ b64::alphabet). Whole-crate paths, lib.rs, Cargo.toml, flake.nix, and the frozen_surface API-pin test updated.

Phase 1b — split by responsibility (26e2bfd): b64/encode.rs + b64/decode.rsb64/int.rs (int↔b64, both directions) + b64/binary.rs (bytes→b64); extracted b64/charset.rs (is_b64_url_safe_charset) out of b64/alphabet.rs. b64/ is now alphabet · int · binary · charset · error.

no_std CI fix (ac513f4): cesr-nostd built alloc,core,b64,keri — omitting stream, even though stream is no_std-clean. Added it so the no_std check exercises the stream parser. (crypto/serder stay out: getrandom has no bare-target backend.)

⚠️ Breaking (public paths)

  • cesr::utils::*cesr::b64::*
  • cargo feature utilsb64
  • submodule paths cesr::b64::encode::* / ::decode::*cesr::b64::int::* / ::binary::*

The re-exports (cesr::b64::encode_int, decode_to_int, encode_binary, is_b64_url_safe_charset) are stable. 0.x → MINOR bump.

Not in this PR (follow-up #57 phases)

Fold stream/util into b64; rename core/utilscore/code_size; naming-convention sweep + CLAUDE.md update; CI trigger dedup. Tracked on #57.

Verification

nix flake check green: clippy, all tests + keripy differential vectors, doctest, cesr-wasm, cesr-nostd (now with stream).

Refs #57

🤖 Generated with Claude Code

Phase 1a of #57. The `utils` module was a non-name for what is the CESR Base64
codec. Rename module + feature `utils` -> `b64`, and rename the inner
`utils::utils` (module inception) to `b64::alphabet`. All crate-wide paths
(`crate::utils::*` -> `crate::b64::*`), the `b64` feature and its dependents
(core, stream, default), and lib.rs updated.

Internal file split (encode/decode -> int/binary, charset.rs) follows in 1b.
`core::utils` (code-size helpers) is a separate module, renamed in a later phase.

BREAKING CHANGE: `cesr::utils::*` is now `cesr::b64::*`; cargo feature `utils`
is now `b64`.

Refs #57
Phase 1b. b64::encode + b64::decode -> b64::int (int<->b64) + b64::binary
(bytes->b64); extract b64::charset (is_b64_url_safe_charset) out of b64::alphabet.
Behaviour-preserving; re-exports (cesr::b64::encode_int etc.) unchanged.

BREAKING CHANGE: submodule paths cesr::b64::encode::* / cesr::b64::decode::*
are now cesr::b64::int::* / cesr::b64::binary::*.

Refs #57
cesr-nostd built alloc,core,b64,keri — omitting stream, even though stream is
no_std-clean (it needs only `bytes`, not getrandom). Add it so the no_std
check actually exercises the stream parser. crypto/serder stay excluded:
getrandom has no RNG backend on a bare target (only the wasm `js` one).

Refs #57
@joeldsouzax joeldsouzax enabled auto-merge July 2, 2026 12:36
@codspeed-hq

codspeed-hq Bot commented Jul 2, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 11 untouched benchmarks


Comparing refactor/57-b64-module (2066545) with main (07a75d4)

Open in CodSpeed

@joeldsouzax joeldsouzax merged commit 5871479 into main Jul 2, 2026
6 checks passed
joeldsouzax added a commit that referenced this pull request Jul 2, 2026
…+ error de-collision) (#62)

* docs(#57): design for killing the utils dumping grounds + naming/error cleanup

Approved design for the remaining #57 work (PR #60 delivered part 1). Locks two
decisions: keep per-module error enums (de-collide names), and keep b64 a pure
primitive leaf with qb64<->qb2 staying code-aware in stream. Refs #57

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* docs(#57): implementation plan + spec refinements (byte lookup, lighter de-collision)

Plan for the remaining #57 work in 7 gated behaviour-preserving tasks. Spec
refined during planning: b64_byte_to_index becomes the single lookup primitive
(char version was only used by decode), and error de-collision renames only
indexer's two enums (resolves both clashes, avoids ~92 edits in matter/). Refs #57

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* refactor(#57): b64 byte lookup + decode_int (was decode_to_int)

b64_char_to_index -> b64_byte_to_index (the single byte lookup primitive);
decode_to_int -> decode_int with AsRef<[u8]> input. Behaviour-preserving.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* refactor(#57): delete stream/util.rs, route int/b64 codecs through b64

int_to_b64 -> b64::encode_int; b64_to_int -> b64::decode_int. Kills the
second 'utils' dumping ground.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* refactor(#57): rename stream/binary.rs -> stream/qb2.rs, drop 3rd b64_val

qb2.rs owns qb64<->qb2; its private b64_val is deleted in favour of
b64::alphabet::b64_byte_to_index. Public stream::qb64_to_qb2 path unchanged.
Also fixes benches/matter.rs (used the old stream::binary module path
directly) and rewords a stream::binary reference in a b64::alphabet.rs
doc comment.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* refactor(#57): move code-size lookups to core/matter/code/hard.rs

Deletes the third 'utils' dumping ground (core/utils.rs); co-locates the
hard-size lookups with their only caller, matter_code.rs.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* refactor(#57): indexer int_to_b64 delegates to b64::encode_int

Removes the last hand-rolled Base64 integer encoder.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* refactor(#57)!: rename indexer ParseError/ValidationError -> Indexer*

BREAKING: de-collides the two error-enum name clashes (stream::ParseError and
matter::ValidationError are now unique). Variants and messages unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* docs(#57): update module table, naming + error conventions, CHANGELOG

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant