Struct tonic::metadata::VacantEntry
source · [−]pub struct VacantEntry<'a, VE: ValueEncoding> { /* private fields */ }
Expand description
A view into a single empty location in a MetadataMap
.
This struct is returned as part of the Entry
enum.
Implementations
sourceimpl<'a, VE: ValueEncoding> VacantEntry<'a, VE>
impl<'a, VE: ValueEncoding> VacantEntry<'a, VE>
sourcepub fn key(&self) -> &MetadataKey<VE>
pub fn key(&self) -> &MetadataKey<VE>
Returns a reference to the entry’s key
Examples
let mut map = MetadataMap::new();
assert_eq!(map.entry("x-hello").unwrap().key(), "x-hello");
sourcepub fn into_key(self) -> MetadataKey<VE>
pub fn into_key(self) -> MetadataKey<VE>
Take ownership of the key
Examples
let mut map = MetadataMap::new();
if let Entry::Vacant(v) = map.entry("x-hello").unwrap() {
assert_eq!(v.into_key().as_str(), "x-hello");
}
sourcepub fn insert(self, value: MetadataValue<VE>) -> &'a mut MetadataValue<VE>
pub fn insert(self, value: MetadataValue<VE>) -> &'a mut MetadataValue<VE>
Insert the value into the entry.
The value will be associated with this entry’s key. A mutable reference to the inserted value will be returned.
Examples
let mut map = MetadataMap::new();
if let Entry::Vacant(v) = map.entry("x-hello").unwrap() {
v.insert("world".parse().unwrap());
}
assert_eq!(map.get("x-hello").unwrap(), "world");
sourcepub fn insert_entry(self, value: MetadataValue<VE>) -> OccupiedEntry<'a, Ascii>
pub fn insert_entry(self, value: MetadataValue<VE>) -> OccupiedEntry<'a, Ascii>
Insert the value into the entry.
The value will be associated with this entry’s key. The new
OccupiedEntry
is returned, allowing for further manipulation.
Examples
let mut map = MetadataMap::new();
if let Entry::Vacant(v) = map.entry("x-hello").unwrap() {
let mut e = v.insert_entry("world".parse().unwrap());
e.insert("world2".parse().unwrap());
}
assert_eq!(map.get("x-hello").unwrap(), "world2");
Trait Implementations
sourceimpl<'a, VE: Debug + ValueEncoding> Debug for VacantEntry<'a, VE>
impl<'a, VE: Debug + ValueEncoding> Debug for VacantEntry<'a, VE>
Auto Trait Implementations
impl<'a, VE> RefUnwindSafe for VacantEntry<'a, VE>where
VE: RefUnwindSafe,
impl<'a, VE> Send for VacantEntry<'a, VE>where
VE: Send,
impl<'a, VE> Sync for VacantEntry<'a, VE>where
VE: Sync,
impl<'a, VE> Unpin for VacantEntry<'a, VE>where
VE: Unpin,
impl<'a, VE> !UnwindSafe for VacantEntry<'a, VE>
Blanket Implementations
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstablefn borrow_mut(&mut self) -> &mut T
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>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T>where
T: Future, type Output = <T as Future>::Output;
fn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T>where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
sourcefn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T>where
T: Future, type Output = <T as Future>::Output;
fn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T>where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T>where
T: Future, type Output = <T as Future>::Output;
fn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T>where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
sourcefn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T>where
T: Future, type Output = <T as Future>::Output;
fn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T>where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T>where
T: Future, type Output = <T as Future>::Output;
where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T>where
T: Future, type Output = <T as Future>::Output;
where
S: Into<Dispatch>,
T: Future, type Output = <T as Future>::Output;
sourcefn with_current_subscriber(self) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T>where
T: Future, type Output = <T as Future>::Output;
fn with_current_subscriber(self) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T>where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T>where
T: Future, type Output = <T as Future>::Output;
where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T>where
T: Future, type Output = <T as Future>::Output;
where
S: Into<Dispatch>,
T: Future, type Output = <T as Future>::Output;
sourcefn with_current_subscriber(self) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T>where
T: Future, type Output = <T as Future>::Output;
fn with_current_subscriber(self) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T>where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;