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 ResponseVal<'_>
impl ResponseVal<'_>
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
§Errors
If the response value can not be parsed into the output
value, a ParsingError
will be returned
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
§Errors
If any of the values in the string can not be parsed into the output
value, the ParsingError
for that value will be 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