Skip to content

chore: remove async-trait, base64, smallvec, thiserror (zero-dependencies pass)#179

Open
Tuntii wants to merge 3 commits into
mainfrom
chore/zero-dependencies
Open

chore: remove async-trait, base64, smallvec, thiserror (zero-dependencies pass)#179
Tuntii wants to merge 3 commits into
mainfrom
chore/zero-dependencies

Conversation

@Tuntii
Copy link
Copy Markdown
Owner

@Tuntii Tuntii commented May 18, 2026

Summary

Zero-dependencies cleanup pass — replaces four external crates with native std equivalents across the workspace.


Changes

async-trait removed from rustapi-jobs

  • Job trait: uses native async fn (Rust 1.75+)
  • JobBackend / JobHandler (dyn-compatible): manual Pin<Box<dyn Future + Send + 'a>> signatures
  • MemoryBackend, RedisBackend, PostgresBackend, test impls all updated with Box::pin(async move { ... })

base64 removed from rustapi-core, rustapi-ws

  • Replaced with an inline 12-line RFC 4648 standard base64 encoder
  • WebSocket accept key generation verified against RFC 6455 test vector:
    "dGhlIHNhbXBsZSBub25jZQ==""s3pPLMBiTxaQ9kYGzzhZRbK+xOo="

smallvec removed from rustapi-core

  • PathParams inner storage: SmallVec<[(String,String); 4]>Vec<(String,String)>
  • STACK_PARAMS_CAPACITY constant removed (was internal-only)
  • spilled() SmallVec-specific tests replaced with equivalent length assertions

thiserror removed from 10 crates + workspace root

Manual Display / std::error::Error / From impls added for every error enum:

Crate Error types
rustapi-ws WebSocketError, AuthError
rustapi-view ViewError
rustapi-extras DieselPoolError, AuditError, ExportError, TokenError, ReplayClientError, PoolError, SessionError
rustapi-core ReplayStoreError
rustapi-toon ToonError
rustapi-jobs JobError

#[from] fields replaced with explicit From impls preserving full error chain via source().


Test results

cargo test --workspace  →  0 failures across all 37 test suites
cargo check --workspace →  EXIT: 0

Removed workspace dependencies

# Before
async-trait = "0.1"   # still used by other crates (rustapi-extras etc.)
base64        — per-crate dep (rustapi-core, rustapi-ws)
smallvec = "1.13"     — per-crate dep (rustapi-core)
thiserror = "2.0"     # workspace root — completely removed

async-trait remains in workspace Cargo.toml as it is still used by rustapi-extras, rustapi-core/replay, and rustapi-validate (dyn trait patterns — deferred to a follow-up).

Replace external crates with native std equivalents:

- async-trait (rustapi-jobs): use native async fn in traits + Pin<Box<dyn Future>>
  for dyn-compatible traits (JobBackend, JobHandler)
- base64 (rustapi-core, rustapi-ws): inline 12-line RFC 4648 encode fn;
  RFC 6455 WebSocket accept key test vector confirmed
- smallvec (rustapi-core): replace PathParams inner storage with Vec<(String,String)>
- thiserror (10 crates + workspace): manual Display/Error/From impls across
  WebSocketError, AuthError, ViewError, DieselPoolError, AuditError,
  ExportError, TokenError, ReplayClientError, PoolError, SessionError,
  ReplayStoreError, ToonError, JobError

All 37 workspace test suites pass (0 failures).
Copilot AI review requested due to automatic review settings May 18, 2026 20:17
@github-actions github-actions Bot added the chore label May 18, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Zero-dependencies cleanup that drops four external crates (async-trait, base64, smallvec, thiserror) across the workspace, replacing them with hand-written std-only equivalents (manual Display/Error/From impls, native async fn in traits + boxed-future for dyn-compat handlers, an inline RFC 4648 base64 encoder, and a Vec-backed PathParams). cargo-rustapi also gates notify behind a new native-watch feature and gains a polling watcher fallback.

Changes:

  • Remove thiserror from 10 crates + workspace root; add manual Display/Error/From impls for each error enum.
  • Remove async-trait from rustapi-jobs (Job uses impl Future; JobBackend/JobHandler use boxed Pin<Box<dyn Future + Send + 'a>>); base64 from rustapi-ws/rustapi-core replaced by an inline encoder; smallvec from rustapi-core (PathParams switched to Vec).
  • cargo-rustapi: drop walkdir (replace with fs::read_dir recursion), gate notify/notify-debouncer-mini behind native-watch feature, add std-only polling watcher and a snapshot-based test.

Reviewed changes

Copilot reviewed 36 out of 37 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
Cargo.toml, Cargo.lock Drop workspace thiserror dep; refresh lockfile (base64, smallvec, thiserror, walkdir, system-configuration, windows-registry removed).
crates/rustapi-core/Cargo.toml Drop thiserror, base64, smallvec deps.
crates/rustapi-core/src/path_params.rs SmallVec-backed PathParams replaced by Vec; docs and spilled() tests removed.
crates/rustapi-core/src/replay/store.rs Manual Display/Error for ReplayStoreError.
crates/rustapi-core/src/app.rs Inline base64_encode helper replaces base64 crate for basic-auth header.
crates/rustapi-ws/{Cargo.toml,src/upgrade.rs,src/error.rs,src/auth.rs} Drop base64/thiserror; inline base64_encode for WS accept key; manual error impls.
crates/rustapi-view/{Cargo.toml,src/error.rs} Drop thiserror; manual error impls.
crates/rustapi-validate/Cargo.toml Drop unused thiserror dep.
crates/rustapi-toon/{Cargo.toml,src/error.rs} Drop thiserror; manual error impls (stale # Error handling comment left behind).
crates/rustapi-testing/Cargo.toml Drop thiserror/tracing/futures-util deps; tighten tokio/hyper features.
crates/rustapi-jobs/Cargo.toml Drop thiserror/futures-util; tighten tokio features.
crates/rustapi-jobs/src/{error.rs,job.rs,backend.rs,backend/memory.rs,backend/redis.rs,backend/postgres.rs,queue.rs} & tests Drop async-trait; Job uses impl Future; JobBackend/JobHandler switch to manual boxed futures; manual error impls.
crates/rustapi-extras/{Cargo.toml,src/diesel/mod.rs,src/sqlx/mod.rs,src/oauth2/tokens.rs,src/session/mod.rs,src/audit/store.rs,src/insight/export.rs,src/replay/client.rs} Drop thiserror; manual Display/Error/From impls for each error type.
crates/cargo-rustapi/Cargo.toml Drop walkdir/thiserror; gate notify* behind new native-watch feature.
crates/cargo-rustapi/src/commands/watch.rs Add std-only polling watcher; feature-gate native notify path; add snapshot test.
crates/cargo-rustapi/src/commands/doctor.rs Replace walkdir with manual fs::read_dir recursion; factor signal application into helper.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +347 to +362
/// RFC 4648 standard base64 encode (no external crate)
fn base64_encode(input: &[u8]) -> String {
const ALPHA: &[u8; 64] =
b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
let mut out = String::with_capacity((input.len() + 2) / 3 * 4);
for chunk in input.chunks(3) {
let b0 = chunk[0] as usize;
let b1 = if chunk.len() > 1 { chunk[1] as usize } else { 0 };
let b2 = if chunk.len() > 2 { chunk[2] as usize } else { 0 };
out.push(ALPHA[b0 >> 2] as char);
out.push(ALPHA[((b0 & 3) << 4) | (b1 >> 4)] as char);
out.push(if chunk.len() > 1 { ALPHA[((b1 & 0xf) << 2) | (b2 >> 6)] as char } else { '=' });
out.push(if chunk.len() > 2 { ALPHA[b2 & 63] as char } else { '=' });
}
out
}
Comment on lines 6 to 9
#[derive(Debug, Clone, Default)]
pub struct PathParams {
inner: SmallVec<[(String, String); STACK_PARAMS_CAPACITY]>,
inner: Vec<(String, String)>,
}
Comment thread crates/rustapi-toon/Cargo.toml Outdated
Tuntii and others added 2 commits May 19, 2026 09:02
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants