chore: remove async-trait, base64, smallvec, thiserror (zero-dependencies pass)#179
Open
Tuntii wants to merge 3 commits into
Open
chore: remove async-trait, base64, smallvec, thiserror (zero-dependencies pass)#179Tuntii wants to merge 3 commits into
Tuntii wants to merge 3 commits into
Conversation
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).
Contributor
There was a problem hiding this comment.
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
thiserrorfrom 10 crates + workspace root; add manualDisplay/Error/Fromimpls for each error enum. - Remove
async-traitfromrustapi-jobs(Jobusesimpl Future;JobBackend/JobHandleruse boxedPin<Box<dyn Future + Send + 'a>>);base64fromrustapi-ws/rustapi-corereplaced by an inline encoder;smallvecfromrustapi-core(PathParamsswitched toVec). cargo-rustapi: dropwalkdir(replace withfs::read_dirrecursion), gatenotify/notify-debouncer-minibehindnative-watchfeature, 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)>, | ||
| } |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Zero-dependencies cleanup pass — replaces four external crates with native
stdequivalents across the workspace.Changes
async-traitremoved fromrustapi-jobsJobtrait: uses nativeasync fn(Rust 1.75+)JobBackend/JobHandler(dyn-compatible): manualPin<Box<dyn Future + Send + 'a>>signaturesMemoryBackend,RedisBackend,PostgresBackend, test impls all updated withBox::pin(async move { ... })base64removed fromrustapi-core,rustapi-ws"dGhlIHNhbXBsZSBub25jZQ=="→"s3pPLMBiTxaQ9kYGzzhZRbK+xOo="smallvecremoved fromrustapi-corePathParamsinner storage:SmallVec<[(String,String); 4]>→Vec<(String,String)>STACK_PARAMS_CAPACITYconstant removed (was internal-only)spilled()SmallVec-specific tests replaced with equivalent length assertionsthiserrorremoved from 10 crates + workspace rootManual
Display/std::error::Error/Fromimpls added for every error enum:rustapi-wsWebSocketError,AuthErrorrustapi-viewViewErrorrustapi-extrasDieselPoolError,AuditError,ExportError,TokenError,ReplayClientError,PoolError,SessionErrorrustapi-coreReplayStoreErrorrustapi-toonToonErrorrustapi-jobsJobError#[from]fields replaced with explicitFromimpls preserving full error chain viasource().Test results
Removed workspace dependencies
async-traitremains in workspaceCargo.tomlas it is still used byrustapi-extras,rustapi-core/replay, andrustapi-validate(dyn trait patterns — deferred to a follow-up).