Add unit tests to ensure null and negative integer request IDs parse successfully.
Changed
Change Id::Number(u64) to Id::Number(i64).
Change Response::error() constructor to accept Id instead of Option<Id>.
Change Response::id() method to return &Id instead of Option<&Id>.
Change Response::into_parts() method to return (Id, _) instead of (Option<Id>, _)
Use std::sync::atomic::AtomicU32 to track client request IDs instead of AtomicU64. This ensures the incrementing IDs will always cast losslessly into an i64 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 parsing null and negative integer request IDs, even if we never emit them ourselves.
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.