pub struct FFRelayApi { /* private fields */ }Expand description
The main API client for interacting with Firefox Relay.
This struct provides methods to create, list, and delete email relays, as well as retrieve profile information.
§Example
use ffrelay_api::api::FFRelayApi;
let api = FFRelayApi::new("your-api-token");
let relays = api.list().await?;Implementations§
Source§impl FFRelayApi
impl FFRelayApi
Sourcepub async fn profiles(&self) -> Result<Vec<FirefoxRelayProfile>>
pub async fn profiles(&self) -> Result<Vec<FirefoxRelayProfile>>
Retrieves all Firefox Relay profiles associated with the API token.
Returns detailed information about your Firefox Relay account including subscription status, usage statistics, and settings.
§Errors
Returns an error if the HTTP request fails or the response cannot be parsed.
§Example
use ffrelay_api::api::FFRelayApi;
let api = FFRelayApi::new("your-api-token");
let profiles = api.profiles().await?;
for profile in profiles {
println!("Total masks: {}", profile.total_masks);
println!("Has premium: {}", profile.has_premium);
}Sourcepub async fn create(&self, request: FirefoxEmailRelayRequest) -> Result<String>
pub async fn create(&self, request: FirefoxEmailRelayRequest) -> Result<String>
Creates a new email relay (alias).
Creates either a random relay (ending in @mozmail.com) or a custom domain relay if you have a premium subscription and provide an address.
§Arguments
request- Configuration for the new relay including description and optional custom address
§Returns
The full email address of the newly created relay.
§Errors
Returns an error if the HTTP request fails, the response cannot be parsed, or you’ve reached your relay limit.
§Example
use ffrelay_api::api::FFRelayApi;
use ffrelay_api::types::FirefoxEmailRelayRequest;
let api = FFRelayApi::new("your-api-token");
// Create a random relay
let request = FirefoxEmailRelayRequest::builder()
.description("For shopping sites".to_string())
.build();
let email = api.create(request).await?;
println!("Created: {}", email);
// Create a custom domain relay (requires premium)
let request = FirefoxEmailRelayRequest::builder()
.description("Newsletter".to_string())
.address("newsletter".to_string())
.build();
let email = api.create(request).await?;Sourcepub async fn list(&self) -> Result<Vec<FirefoxEmailRelay>>
pub async fn list(&self) -> Result<Vec<FirefoxEmailRelay>>
Lists all email relays (both random and domain relays).
Retrieves all active email relays associated with your account, including both standard relays (@mozmail.com) and custom domain relays.
§Returns
A vector of all email relays with their statistics and metadata.
§Errors
Returns an error only if both standard and domain relay requests fail. If one succeeds, returns the available relays.
§Example
use ffrelay_api::api::FFRelayApi;
let api = FFRelayApi::new("your-api-token");
let relays = api.list().await?;
for relay in relays {
println!("{}: {} (forwarded: {})",
relay.id,
relay.full_address,
relay.num_forwarded
);
}Sourcepub async fn delete(&self, email_id: u64) -> Result<()>
pub async fn delete(&self, email_id: u64) -> Result<()>
Deletes an email relay by its ID.
Permanently removes the specified email relay. The relay will stop forwarding emails immediately. This action cannot be undone.
§Arguments
email_id- The unique ID of the relay to delete
§Errors
Returns an error if:
- The relay ID is not found
- The HTTP request fails
- The deletion request is rejected by the server
§Example
use ffrelay_api::api::FFRelayApi;
let api = FFRelayApi::new("your-api-token");
// Delete a relay by ID
api.delete(12345678).await?;
println!("Relay deleted successfully");