Enum sp_rpc::list::ListOrValue
source · [−]pub enum ListOrValue<T> {
List(Vec<T>),
Value(T),
}
Expand description
RPC list or value wrapper.
For some RPCs it’s convenient to call them with either a single value or a whole list of values to get a proper response. In theory you could do a batch query, but it’s:
- Less convenient in client libraries
- If the response value is small, the protocol overhead might be dominant.
Also it’s nice to be able to maintain backward compatibility for methods that were initially taking a value and now we want to expand them to take a list.
Variants
List(Vec<T>)
A list of values of given type.
Value(T)
A single value of given type.
Implementations
sourceimpl<T> ListOrValue<T>
impl<T> ListOrValue<T>
sourcepub fn map<F: Fn(T) -> X, X>(self, f: F) -> ListOrValue<X>
pub fn map<F: Fn(T) -> X, X>(self, f: F) -> ListOrValue<X>
Map every contained value using function F
.
This allows to easily convert all values in any of the variants.
Trait Implementations
sourceimpl<T: Debug> Debug for ListOrValue<T>
impl<T: Debug> Debug for ListOrValue<T>
sourceimpl<'de, T> Deserialize<'de> for ListOrValue<T> where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for ListOrValue<T> where
T: Deserialize<'de>,
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl<T> From<T> for ListOrValue<T>
impl<T> From<T> for ListOrValue<T>
sourceimpl<T> From<Vec<T, Global>> for ListOrValue<T>
impl<T> From<Vec<T, Global>> for ListOrValue<T>
sourceimpl<T: PartialEq> PartialEq<ListOrValue<T>> for ListOrValue<T>
impl<T: PartialEq> PartialEq<ListOrValue<T>> for ListOrValue<T>
sourcefn eq(&self, other: &ListOrValue<T>) -> bool
fn eq(&self, other: &ListOrValue<T>) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &ListOrValue<T>) -> bool
fn ne(&self, other: &ListOrValue<T>) -> bool
This method tests for !=
.
sourceimpl<T> Serialize for ListOrValue<T> where
T: Serialize,
impl<T> Serialize for ListOrValue<T> where
T: Serialize,
impl<T> StructuralPartialEq for ListOrValue<T>
Auto Trait Implementations
impl<T> RefUnwindSafe for ListOrValue<T> where
T: RefUnwindSafe,
impl<T> Send for ListOrValue<T> where
T: Send,
impl<T> Sync for ListOrValue<T> where
T: Sync,
impl<T> Unpin for ListOrValue<T> where
T: Unpin,
impl<T> UnwindSafe for ListOrValue<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T, Outer> IsWrappedBy<Outer> for T where
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>,
impl<T, Outer> IsWrappedBy<Outer> for T where
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>,
sourceimpl<S, T> UncheckedInto<T> for S where
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for S where
T: UncheckedFrom<S>,
sourcepub fn unchecked_into(self) -> T
pub fn unchecked_into(self) -> T
The counterpart to unchecked_from
.