Support null and negative integer request IDs #285
Merged
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.
Added
Id::Null
enum variant.Default
forId
.null
and negative integer request IDs parse successfully.Changed
Id::Number(u64)
toId::Number(i64)
.Response::error()
constructor to acceptId
instead ofOption<Id>
.Response::id()
method to return&Id
instead ofOption<&Id>
.Response::into_parts()
method to return(Id, _)
instead of(Option<Id>, _)
std::sync::atomic::AtomicU32
to track client request IDs instead ofAtomicU64
. This ensures the incrementing IDs will always cast losslessly into ani64
primitive data type.Both of these request ID types are rare and bizarre and their use is generally discouraged by the JSON-RPC 2.0 spec, but are nonetheless permitted by the standard. Since we wish
tower-lsp
to be compatible with as many JSON-RPC client libraries as possible, we must support parsingnull
and negative integer request IDs, even if we never emit them ourselves.