pub struct JsonNamedParamsBuilder { /* private fields */ }Expand description
Builder for named JSON parameters.
§Example
use hyperdb_api_core::client::grpc::QueryParameters;
let params = QueryParameters::json_named()
.add("user_id", &123)?
.add("email", &"user@example.com")?
.build();Implementations§
Source§impl JsonNamedParamsBuilder
impl JsonNamedParamsBuilder
Sourcepub fn add<T: Serialize>(
self,
name: impl Into<String>,
value: &T,
) -> Result<Self, Error>
pub fn add<T: Serialize>( self, name: impl Into<String>, value: &T, ) -> Result<Self, Error>
Adds a named parameter.
§Arguments
name- Parameter name (without the colon prefix)value- Parameter value (must be JSON-serializable)
§Errors
Returns a serde_json::Error if value cannot be serialized
to JSON.
Sourcepub fn build(self) -> QueryParameters
pub fn build(self) -> QueryParameters
Builds the QueryParameters.
§Panics
Does not panic in practice. The serde_json::to_string call on a
Map<String, Value> is infallible for valid JSON trees —
serde_json only fails when a user-defined Serialize impl
returns an error, which cannot happen for the already-validated
Value payloads inserted via Self::add and Self::add_null.
Trait Implementations§
Source§impl Debug for JsonNamedParamsBuilder
impl Debug for JsonNamedParamsBuilder
Source§impl Default for JsonNamedParamsBuilder
impl Default for JsonNamedParamsBuilder
Source§fn default() -> JsonNamedParamsBuilder
fn default() -> JsonNamedParamsBuilder
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for JsonNamedParamsBuilder
impl RefUnwindSafe for JsonNamedParamsBuilder
impl Send for JsonNamedParamsBuilder
impl Sync for JsonNamedParamsBuilder
impl Unpin for JsonNamedParamsBuilder
impl UnsafeUnpin for JsonNamedParamsBuilder
impl UnwindSafe for JsonNamedParamsBuilder
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request