Struct space_email_api::SpaceEmailClient
source · pub struct SpaceEmailClient { /* private fields */ }
Expand description
A client capable of sending and downloading space emails, as well as managing the stars of a space email account.
Implementations§
source§impl SpaceEmailClient
impl SpaceEmailClient
sourcepub fn new() -> Result<SpaceEmailClient, SpaceEmailError>
pub fn new() -> Result<SpaceEmailClient, SpaceEmailError>
Creates a new SpaceEmailClient
. This method returns Err
if and only if
it is unable to create a new reqwest::Client
internally.
sourcepub async fn login(
&mut self,
email: &str,
password: &str
) -> Result<(), SpaceEmailError>
pub async fn login( &mut self, email: &str, password: &str ) -> Result<(), SpaceEmailError>
Attempts to login to space email with the provided credentials.
sourcepub async fn logout(&mut self) -> Result<(), SpaceEmailError>
pub async fn logout(&mut self) -> Result<(), SpaceEmailError>
Attempts to log out of space email.
sourcepub async fn get_random(&self) -> Result<SpaceEmail, SpaceEmailError>
pub async fn get_random(&self) -> Result<SpaceEmail, SpaceEmailError>
Attempts to download a random space email.
sourcepub async fn get_random_in_range(
&self,
range: SpaceEmailRange
) -> Result<SpaceEmail, SpaceEmailError>
pub async fn get_random_in_range( &self, range: SpaceEmailRange ) -> Result<SpaceEmail, SpaceEmailError>
Attempts to download a random space email sent during the time range specified by range
. If this client
is not logged in, range must equal SpaceEmailRange::All
, else Err(SpaceEmailError::RequiresLogin)
will be returned.
sourcepub async fn get_by_id(
&self,
id: impl Into<EmailId>
) -> Result<SpaceEmail, SpaceEmailError>
pub async fn get_by_id( &self, id: impl Into<EmailId> ) -> Result<SpaceEmail, SpaceEmailError>
Attempts to download the space email with id id
. Due to technical limitations, it is not always
possible to detect the email’s proper color with this method, and emails with a style
of
SpaceEmailStyle::Yellow
may be returned when the email’s actual color differs.
sourcepub async fn send(
&self,
email: &SpaceEmailContents
) -> Result<(), SpaceEmailError>
pub async fn send( &self, email: &SpaceEmailContents ) -> Result<(), SpaceEmailError>
Attempts to send an email with the specified SpaceEmailContents
.
sourcepub async fn star(
&self,
email: impl Into<EmailId>
) -> Result<(), SpaceEmailError>
pub async fn star( &self, email: impl Into<EmailId> ) -> Result<(), SpaceEmailError>
Attempts to star the specified email. Returns Err(SpaceEmailError::RequiresLogin)
if the
client is not logged in.
sourcepub async fn unstar(
&self,
email: impl Into<EmailId>
) -> Result<(), SpaceEmailError>
pub async fn unstar( &self, email: impl Into<EmailId> ) -> Result<(), SpaceEmailError>
Attempts to unstar the specified email. Returns Err(SpaceEmailError::RequiresLogin)
if the
client is not logged in.
sourcepub fn starred_emails<'a>(
&'a self
) -> Result<impl Stream<Item = Result<EmailId, SpaceEmailError>> + 'a, SpaceEmailError>
pub fn starred_emails<'a>( &'a self ) -> Result<impl Stream<Item = Result<EmailId, SpaceEmailError>> + 'a, SpaceEmailError>
Provides a stream of EmailId
s corresponding to emails starred by the currently logged-in user. To
obtain the emails themselves, pass the result of this method to SpaceEmailClient::get_by_id
.
Returns Err(SpaceEmailError::RequiresLogin)
if the client is not logged in.