Struct thrift_codec::data::Map

source ·
pub struct Map(/* private fields */);
Expand description

Map.

Internally this is represented by the data structure called “associative array”. No duplicate keys are removed.

Implementations§

source§

impl Map

source

pub fn empty() -> Self

Makes an empty Map instance.

Note that the returning value could not be encoded by the binary protocol encoding.

source

pub fn new<I, K, V>(pairs: I) -> Self
where I: Iterator<Item = (K, V)>, Vec<K>: Into<Elements>, Vec<V>: Into<Elements>,

Makes a new Map instance.

source

pub fn from_keys_and_values(keys: Elements, values: Elements) -> Result<Self>

Makes a new Map instance from the separate keys and values.

Errors

If the lengths of keys and values are differed, this function will return an error which kind is ErrorKind::InvalidInput.

source

pub fn get(&self, index: usize) -> Option<(DataRef<'_>, DataRef<'_>)>

Returns the entry placed at the specified index.

source

pub fn iter(&self) -> MapIter<'_>

Returns an iterator over this map.

source

pub fn key_kind(&self) -> Option<DataKind>

Returns the kind of the keys in this map.

source

pub fn value_kind(&self) -> Option<DataKind>

Returns the kind of the values in this map.

source

pub fn len(&self) -> usize

Returns the number of the entries in this map.

source

pub fn is_empty(&self) -> bool

Returns true if this map has no entries.

Trait Implementations§

source§

impl BinaryDecode for Map

source§

fn binary_decode<R: Read>(reader: &mut R) -> Result<Self>

Decodes an object.
source§

impl BinaryEncode for Map

source§

fn binary_encode<W: Write>(&self, writer: &mut W) -> Result<()>

Encodes an object.
source§

impl Clone for Map

source§

fn clone(&self) -> Map

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl CompactDecode for Map

source§

fn compact_decode<R: Read>(reader: &mut R) -> Result<Self>

Decodes an object.
source§

impl CompactEncode for Map

source§

fn compact_encode<W: Write>(&self, writer: &mut W) -> Result<()>

Encodes an object.
source§

impl Debug for Map

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<Map> for Data

source§

fn from(f: Map) -> Self

Converts to this type from the input type.
source§

impl PartialEq for Map

source§

fn eq(&self, other: &Map) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl StructuralPartialEq for Map

Auto Trait Implementations§

§

impl RefUnwindSafe for Map

§

impl Send for Map

§

impl Sync for Map

§

impl Unpin for Map

§

impl UnwindSafe for Map

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.