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

source

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.

source

pub async fn login( &mut self, email: &str, password: &str ) -> Result<(), SpaceEmailError>

Attempts to login to space email with the provided credentials.

source

pub async fn logout(&mut self) -> Result<(), SpaceEmailError>

Attempts to log out of space email.

source

pub async fn get_random(&self) -> Result<SpaceEmail, SpaceEmailError>

Attempts to download a random space email.

source

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.

source

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.

source

pub async fn send( &self, email: &SpaceEmailContents ) -> Result<(), SpaceEmailError>

Attempts to send an email with the specified SpaceEmailContents.

source

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.

source

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.

source

pub fn starred_emails<'a>( &'a self ) -> Result<impl Stream<Item = Result<EmailId, SpaceEmailError>> + 'a, SpaceEmailError>

Provides a stream of EmailIds 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.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more