pub struct JmapRequestBuilder { /* private fields */ }Expand description
Fluent builder for multi-method JmapRequest objects.
Collects method calls and produces a JmapRequest ready for dispatch.
The using capability URIs passed to new apply to the whole request;
callers must include every capability required by the methods they add.
Spec: RFC 8620 §3.3
Implementations§
Source§impl JmapRequestBuilder
impl JmapRequestBuilder
Sourcepub fn new(using: &[&str]) -> Self
pub fn new(using: &[&str]) -> Self
Create a new builder with the given capability URIs.
The using list MUST include "urn:ietf:params:jmap:core" (always
required by RFC 8620 §3.3) plus every capability URI needed by the
methods added via add_call. An
incorrect or empty using list will cause the server to return an
"unknownCapability" error — the builder does not validate it.
Sourcepub fn add_call(
&mut self,
method: impl Into<String>,
args: Value,
call_id: impl Into<String>,
) -> Result<&mut Self, ClientError>
pub fn add_call( &mut self, method: impl Into<String>, args: Value, call_id: impl Into<String>, ) -> Result<&mut Self, ClientError>
Add one method call to the request.
call_id must be unique within this request; callers use it to match
responses back to the originating call.
Returns Err(ClientError::InvalidArgument) if call_id has already
been used in this builder. Duplicate call IDs violate RFC 8620 §3.5.
Sourcepub fn build(self) -> Result<JmapRequest, ClientError>
pub fn build(self) -> Result<JmapRequest, ClientError>
Consume the builder and produce the JmapRequest.
Returns Err(ClientError::InvalidArgument) if no method calls have
been added. An empty methodCalls array is invalid per RFC 8620 §3.3.