feat(net-core): composition primitives#14
Merged
Conversation
- Add workspace deps: bytes, http, http-body, futures-core, futures-sink - Wire crates/net/core/Cargo.toml with those deps (zero runtime deps) - Implement service.rs: Service, Layer, ServiceBuilder, Identity, Stack - Implement error_kind.rs: ErrorKind, HasErrorKind - Update lib.rs: module declarations and pub re-exports - ServiceBuilder derives Clone; layer() is #[must_use]
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.
Closes #12
Summary
Implements the zero-runtime composition primitives for
oath-net-core— the foundation every other network crate builds on.Changes
Cargo.toml(root)Added five new workspace dependencies required by
net-core:bytes,http,http-body,futures-core,futures-sinkcrates/net/core/Cargo.tomlWired the five workspace deps. No
tokio,hyper,serde, orthiserror— the zero-runtime constraint is preserved.crates/net/core/src/service.rs(new)Service<Req>trait — RPITIT return type,&selfreceiver, nopoll_readyLayer<S>trait — wraps one service into anotherServiceBuilder<L>— compile-time compositor; first.layer()call is permanently outermost; derivesClone;layer()is#[must_use]Identity— no-op layer; termination case for theStackrecursionStack<Inner, Outer>— composes two layers;Innerapplied first (closer to leaf),Outerexecutes first on requestscrates/net/core/src/error_kind.rs(new)ErrorKind— coarse middleware routing enum (Timeout,Connection,Throttled,Auth,Client,Server,Unknown);#[non_exhaustive]HasErrorKind— implemented by backend error types so middleware layers can branch without inspecting concrete typescrates/net/core/src/lib.rsUpdated with module declarations and
pub usere-exports for all public types.Design decisions
Send + Syncsupertrait onService— kept general so test doubles, single-threaded adapters, and WASM targets can implement the trait; call sites that require thread-safety add their own boundsasync fnin traits — RPITIT (fn → impl Future + Send) avoidsasync-trait, boxing, and per-call allocationdynanywhere — entire stack resolves to a single monomorphized type at compile time; zero virtual dispatch on the hot path