pub struct ApiKey(/* private fields */);
Expand description
is the container of the api key validated.
To check validity of the given api key, users need to create an api key variable via
ApiKey::from
.
Implementations§
Source§impl<'a> ApiKey
impl<'a> ApiKey
Sourcepub fn from(key: String) -> Result<ApiKey, ReturnError>
pub fn from(key: String) -> Result<ApiKey, ReturnError>
is needed to automatically check validation of api key for new instance.
The internet connection is required to achieve the task.
§Error
The function will return error if given api key is invalid or there is a bad internet connection.
§Examples
use tcmb_evds::common::ApiKey;
use tcmb_evds::error::ReturnError;
// If user key entered is valid, the function creates api_key variable.
// Otherwise, returns one of ReturnError options.
// The function returns an error unless users write their own valid api key.
let result = ApiKey::from("users_key".to_string());
// Users can handle error in a different way.
let api_key = match result {
Err(return_error) => {
println!("{}", return_error.to_string());
return;
},
Ok(api_key) => api_key,
};
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ApiKey
impl RefUnwindSafe for ApiKey
impl Send for ApiKey
impl Sync for ApiKey
impl Unpin for ApiKey
impl UnwindSafe for ApiKey
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more