pub struct Params { /* private fields */ }Expand description
Builds a call’s params object from typed arguments — what a generated client method does with its parameters before it calls the transport.
Keys are the method’s parameter names, which are what its schema
declares. An Option parameter that is None is omitted, not sent
as null (optional): the shape a server with
skip_serializing_if = "Option::is_none" sends, and the one menger’s
REST tests assert.
The first argument that does not serialize is kept as
ClientError::Encode and build returns it — nothing is
sent, and nothing panics (a panic in a wasm32 consumer is an
unrecoverable trap).
use plexus_client::Params;
let params = Params::new()
.param("id", "MNG-2")
.optional("epic", None::<String>)
.build()
.unwrap();
assert_eq!(params, serde_json::json!({"id": "MNG-2"}));Implementations§
Source§impl Params
impl Params
Sourcepub fn param<V: Serialize>(self, name: &'static str, value: V) -> Self
pub fn param<V: Serialize>(self, name: &'static str, value: V) -> Self
Add name with value, always.
Sourcepub fn optional<V: Serialize>(
self,
name: &'static str,
value: Option<V>,
) -> Self
pub fn optional<V: Serialize>( self, name: &'static str, value: Option<V>, ) -> Self
Add name when value is Some; omit it when None.
Sourcepub fn build(self) -> Result<Value, ClientError>
pub fn build(self) -> Result<Value, ClientError>
The params object, or the first argument that would not encode.
Trait Implementations§
Auto Trait Implementations§
impl Forget for Params
impl Freeze for Params
impl RefUnwindSafe for Params
impl Send for Params
impl Sync for Params
impl Unpin for Params
impl UnsafeUnpin for Params
impl UnwindSafe for Params
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more