Struct sf_api::session::ResponseVal
source · pub struct ResponseVal<'a> { /* private fields */ }
Expand description
This is the raw &str, that the server send as a value to some key. This often requires extra conversions/parsing to use practically, so we associate the most common parsing functions as methods to this data.
Implementations§
source§impl<'a> ResponseVal<'a>
impl<'a> ResponseVal<'a>
sourcepub fn into<T: FromStr>(self, name: &'static str) -> Result<T, SFError>
pub fn into<T: FromStr>(self, name: &'static str) -> Result<T, SFError>
Converts the response value into the required type
sourcepub fn into_list<T: FromStr>(
self,
name: &'static str
) -> Result<Vec<T>, SFError>
pub fn into_list<T: FromStr>( self, name: &'static str ) -> Result<Vec<T>, SFError>
Converts the repsponse into a list, by splitting the raw value by ‘/’ and converting each value into the required type. If any conversion fails, an error is returned
sourcepub fn sub_key(&self) -> &str
pub fn sub_key(&self) -> &str
The way keys are parsed will trim some info from the string. The key for
the player save ownplayersave
is actually ownplayersave.playerSave
.
As this .playerSave
is not relevant here and not in most cases, I
decided to trim that off. More common, this is also just s
, r
, or a
size hint like (10)
. In some cases though, this information can be
helpful for parsing. Thus, you can access it here
Trait Implementations§
source§impl<'a> Clone for ResponseVal<'a>
impl<'a> Clone for ResponseVal<'a>
source§fn clone(&self) -> ResponseVal<'a>
fn clone(&self) -> ResponseVal<'a>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more