Struct mpd_protocol::response::frame::Frame
source · pub struct Frame { /* private fields */ }
Expand description
A successful response to a command.
Consists of zero or more key-value pairs, where the keys are not unique, and optionally a single binary blob.
Implementations§
source§impl Frame
impl Frame
sourcepub fn fields_len(&self) -> usize
pub fn fields_len(&self) -> usize
Get the number of key-value pairs in this response frame.
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true
if the frame is entirely empty, i.e. contains 0 key-value pairs and no
binary blob.
sourcepub fn has_binary(&self) -> bool
pub fn has_binary(&self) -> bool
Returns true
if the frame contains a binary blob.
If the binary blob has been removed using Frame::take_binary
, this will return false
.
sourcepub fn fields(&self) -> Fields<'_> ⓘ
pub fn fields(&self) -> Fields<'_> ⓘ
Returns an iterator over all key-value pairs in this frame, in the order they appear in the response.
If keys have been removed using Frame::get
, they will not appear.
sourcepub fn find<K>(&self, key: K) -> Option<&str>
pub fn find<K>(&self, key: K) -> Option<&str>
Find the first key-value pair with the given key, and return a reference to its value.
The key is case-sensitive.
sourcepub fn binary(&self) -> Option<&[u8]>
pub fn binary(&self) -> Option<&[u8]>
Returns a reference to the binary blob in this frame, if there is one.
If the binary blob has been removed using Frame::take_binary
, this will return None
.
sourcepub fn get<K>(&mut self, key: K) -> Option<String>
pub fn get<K>(&mut self, key: K) -> Option<String>
Find the first key-value pair with the given key, and return its value.
The key is case-sensitive. This removes it from the list of fields in this frame.
sourcepub fn take_binary(&mut self) -> Option<BytesMut>
pub fn take_binary(&mut self) -> Option<BytesMut>
Get the binary blob contained in this frame, if present.
This will remove it from the frame, future calls to this method will return None
.