Skip to content

Add record field retention helpers#22

Merged
weasel-lee merged 4 commits intomasterfrom
codex/suggest-refactor-for-github-actions-testing
Jan 15, 2026
Merged

Add record field retention helpers#22
weasel-lee merged 4 commits intomasterfrom
codex/suggest-refactor-for-github-actions-testing

Conversation

@weasel-lee
Copy link
Owner

Motivation

  • Provide an API to filter record fields in-place without reallocating the record buffer via a retain method.
  • Complement existing in-place trimming behavior so callers can both trim and filter fields efficiently.
  • Keep UTF-8 correctness for StringRecord while reusing the byte-level representation for performance.

Description

  • Added pub fn retain<F>(&mut self, keep: F) to ByteRecord that compacts fields in-place by copying kept fields and updating bounds.len and bounds.ends accordingly.
  • Added pub fn retain<F>(&mut self, keep: F) to StringRecord which delegates to the underlying byte-level retain and converts slices to &str with unsafe { str::from_utf8_unchecked(...) } for predicate calls.
  • Introduced/used trimming helper functions (trim_ascii_range and trim_unicode_range) and switched trimming implementations to operate in-place using copy_within and write indices.
  • Added unit tests named retain_fields to both src/byte_record.rs and src/string_record.rs to verify retention behavior alongside existing trimming tests.

Testing

  • Added unit tests retain_fields in src/byte_record.rs and src/string_record.rs covering typical retention scenarios.
  • Existing unit tests for trim and other record invariants were left intact.
  • No automated test run was executed as part of this change (cargo test was not run).
  • CI/build status is not known from this rollout.

Codex Task

@weasel-lee
Copy link
Owner Author

@codex

METADATA_JOB_REQUEST_V1
METADATA_ON_CREATE_SHA:33a3884d9c0bad505ad4d6e591de3b9399120314

Please update Rust metadata files for this PR. Submit the result directly to GitHub (commit) without asking for toggles or confirmations.

Rules:

  • Allowlist: use glob patterns from .github/metadata/allowlist.txt (supports !exclude lines).
  • Output path mapping: /path/to/src/a.rs -> /path/to/src/a.metadata.txt
  • Prompt: follow .github/metadata/prompt.txt exactly for output structure and style.
  • Added Rust file: generate metadata from Rust source + prompt.
  • Modified Rust file: update metadata using Rust source + existing metadata + prompt.
  • Deleted Rust file: if corresponding .metadata.txt exists, delete it.
  • Skip Rust files < 100 lines; include list of skipped files in summary.

Targets:
Added:
(none)

Modified:

  • src/byte_record.rs
  • src/string_record.rs

Deleted:
(none)

@chatgpt-codex-connector
Copy link

Summary

Testing

  • Not run (metadata-only change).

View task →

@weasel-lee weasel-lee merged commit ca29219 into master Jan 15, 2026
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