Tags: init4tech/ajj
Tags
feat!: add IntoErrorPayload trait for structured JSON-RPC errors (#42) * feat: add IntoErrorPayload trait and InternalError wrapper Adds the public IntoErrorPayload trait with error_code, error_message, error_data, and into_error_payload methods. Adds convenience impls for ErrorPayload, InternalError<T>, String, &'static str, and (). ENG-2085 Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> * feat: add internal IntoResponsePayload trait Unifies Result and ResponsePayload conversion paths for the handler macro. Result<T, E: IntoErrorPayload> delegates to into_error_payload(). ResponsePayload<T, E> passes through unchanged. ENG-2085 Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> * refactor: switch handler macro from .into() to .into_response_payload() Prepares for IntoErrorPayload by routing through the new internal IntoResponsePayload trait instead of From<Result<T, E>>. Also updates OutputResult handler bounds from ErrData: RpcSend to ErrData: IntoErrorPayload, as these changes are co-dependent. ENG-2085 Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> * feat!: remove old From impls and convert_internal_error_msg BREAKING: Removes From<Result<T, E>> for ResponsePayload, From<T> for ErrorPayload<T> where T: Error + RpcSend, and ResponsePayload::convert_internal_error_msg. These are replaced by the IntoErrorPayload and IntoResponsePayload traits. ENG-2085 Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> * docs: update Handler trait rustdoc for IntoErrorPayload ENG-2085 Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> * docs: update lib.rs module docs for IntoErrorPayload ENG-2085 Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> * docs: update examples and comments for IntoErrorPayload ENG-2085 Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> * chore: bump version to 0.7.0 Breaking changes in this release: - Handler Result<T, E> error types must implement IntoErrorPayload - String/&str errors now populate the message field (not data) - Removed From<Result> for ResponsePayload, From<T> for ErrorPayload, and convert_internal_error_msg Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> * feat: add magic8ball example showcasing IntoErrorPayload Demonstrates custom error types with per-variant JSON-RPC error codes, messages, and structured error data via the IntoErrorPayload trait. ENG-2085 Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> * refactor: remove blanket From<T> on InternalError, gitignore docs/ Remove the blanket `From<T>` impl on `InternalError<T>` so that wrapping a value requires explicit `InternalError(val)` construction. This prevents silent semantic shifts when switching between `String` (→ message field) and `InternalError<String>` (→ data field) as handler error types. Also gitignore /docs to prevent plan files from being committed. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
feat: add permit APIs and notification_capacity to HandlerCtx (#40) Expose backpressure-aware permit APIs on HandlerCtx that mirror tokio's mpsc::Sender reserve surface. Users can now reserve channel capacity before sending, with both borrowed and owned permit types. New types: NotifyPermit, OwnedNotifyPermit New methods: permit, permit_owned, try_permit, try_permit_owned, permit_many, try_permit_many, notification_capacity Co-authored-by: Claude Opus 4.6 <[email protected]>
feat!: add consuming into_raw_value to RpcSend (#37) * feat!: add consuming `into_raw_value` to `RpcSend`, remove `Serialize` supertrait `RpcSend` previously required `Serialize` as a supertrait, forcing lazy producers like iterators to use `Mutex<Option<T>>` wrappers for interior mutability during serialization. This replaces the marker trait with a consuming `into_raw_value(self)` method, enabling direct ownership transfer during serialization. The blanket impl for `T: Serialize` is preserved, so all existing code that returns `Serialize` types from handlers continues to work. Types that do not implement `Serialize` can now implement `RpcSend` directly with custom serialization logic. BREAKING CHANGE: `RpcSend` no longer has `Serialize` as a supertrait. Code that used `T: RpcSend` and relied on the `Serialize` bound will need to add an explicit `Serialize` bound. `HandlerCtx::notify` now takes `T` by value instead of `&T` (callers passing `&item` still work via the blanket impl). Co-Authored-By: Claude Opus 4.6 <[email protected]> * fix: address review feedback - Deprecate `ErrorPayload::serialize_payload` in favor of `into_raw` - Eliminate extra serialization round in `build_response` by constructing the JSON envelope directly via format!, bypassing the Response struct Co-Authored-By: Claude Opus 4.6 <[email protected]> * fix: use types instead of hand-crafted JSON in response serialization Co-Authored-By: Claude Opus 4.6 <[email protected]> * refactor: generalize Response Serialize bounds to RpcSend Response now owns the payload via Cell<Option<...>> so the Serialize impl can consume it. Bounds are T: RpcSend, E: RpcSend instead of T: Serialize, E: Serialize. build_response no longer needs to call into_raw explicitly — it's handled inside the Serialize impl. Co-Authored-By: Claude Opus 4.6 <[email protected]> * Revert "refactor: generalize Response Serialize bounds to RpcSend" This reverts commit 1383288. * fix: memoize parse_error response and serialization_failure payload - parse_error() now clones from a LazyLock<Box<RawValue>> instead of serializing on every call - serialization_failure() borrows a static ResponsePayload instead of reconstructing it per invocation Co-Authored-By: Claude Opus 4.6 <[email protected]> --------- Co-authored-by: Claude Opus 4.6 <[email protected]>
PreviousNext