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§
Implementations§
source§impl<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§
source§impl<T: Debug> Debug for ListOrValue<T>
impl<T: Debug> Debug for ListOrValue<T>
source§impl<'de, T> Deserialize<'de> for ListOrValue<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for ListOrValue<T>where T: Deserialize<'de>,
source§fn 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
source§impl<T> From<T> for ListOrValue<T>
impl<T> From<T> for ListOrValue<T>
source§impl<T: PartialEq> PartialEq<ListOrValue<T>> for ListOrValue<T>
impl<T: PartialEq> PartialEq<ListOrValue<T>> for ListOrValue<T>
source§fn 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 ==
.source§impl<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§
§impl<T> FromFd for Twhere
T: From<OwnedFd>,
impl<T> FromFd for Twhere T: From<OwnedFd>,
§impl<T> FromFilelike for Twhere
T: From<OwnedFd>,
impl<T> FromFilelike for Twhere T: From<OwnedFd>,
§fn from_filelike(owned: OwnedFd) -> T
fn from_filelike(owned: OwnedFd) -> T
Constructs a new instance of
Self
from the given filelike object. Read more§fn from_into_filelike<Owned>(owned: Owned) -> Twhere
Owned: IntoFilelike,
fn from_into_filelike<Owned>(owned: Owned) -> Twhere Owned: IntoFilelike,
Constructs a new instance of
Self
from the given filelike object
converted from into_owned
. Read more§impl<T> FromSocketlike for Twhere
T: From<OwnedFd>,
impl<T> FromSocketlike for Twhere T: From<OwnedFd>,
§fn from_socketlike(owned: OwnedFd) -> T
fn from_socketlike(owned: OwnedFd) -> T
Constructs a new instance of
Self
from the given socketlike object.§fn from_into_socketlike<Owned>(owned: Owned) -> Twhere
Owned: IntoSocketlike,
fn from_into_socketlike<Owned>(owned: Owned) -> Twhere Owned: IntoSocketlike,
Constructs a new instance of
Self
from the given socketlike object
converted from into_owned
.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, Outer> IsWrappedBy<Outer> for Twhere
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>,
impl<T, Outer> IsWrappedBy<Outer> for Twhere Outer: AsRef<T> + AsMut<T> + From<T>, T: From<Outer>,
§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere T: UncheckedFrom<S>,
source§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
The counterpart to
unchecked_from
.