FFRelayApi

Struct FFRelayApi 

Source
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

Source

pub fn new<T>(token: T) -> Self
where T: Into<String>,

Creates a new Firefox Relay API client.

§Arguments
  • token - Your Firefox Relay API token
§Example
use ffrelay_api::api::FFRelayApi;

let api = FFRelayApi::new("your-api-token");
Source

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);
}
Source

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?;
Source

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
    );
}
Source

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");
Source

pub async fn disable(&self, email_id: u64) -> Result<()>

Disables an email relay by its ID.

When a relay is disabled, it will stop forwarding emails but remain in your account. You can re-enable it later without losing its statistics or configuration.

§Arguments
  • email_id - The unique ID of the relay to disable
§Errors

Returns an error if:

  • The relay ID is not found
  • The HTTP request fails
  • The update request is rejected by the server
§Example
use ffrelay_api::api::FFRelayApi;

let api = FFRelayApi::new("your-api-token");

// Disable a relay temporarily
api.disable(12345678).await?;
println!("Relay disabled successfully");
Source

pub async fn enable(&self, email_id: u64) -> Result<()>

Enables an email relay by its ID.

When a relay is enabled, it will start forwarding emails to your real email address. This is useful for re-enabling a previously disabled relay.

§Arguments
  • email_id - The unique ID of the relay to enable
§Errors

Returns an error if:

  • The relay ID is not found
  • The HTTP request fails
  • The update request is rejected by the server
§Example
use ffrelay_api::api::FFRelayApi;

let api = FFRelayApi::new("your-api-token");

// Enable a previously disabled relay
api.enable(12345678).await?;
println!("Relay enabled successfully");

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

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

Source§

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 T
where U: TryFrom<T>,

Source§

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