pub struct FcmRouter {
settings: FcmSettings,
endpoint_url: Url,
metrics: Arc<StatsdClient>,
db: Box<dyn DbClient>,
clients: HashMap<String, FcmClient>,
}
Expand description
Firebase Cloud Messaging router
Fields§
§settings: FcmSettings
§endpoint_url: Url
§metrics: Arc<StatsdClient>
§db: Box<dyn DbClient>
§clients: HashMap<String, FcmClient>
A map from application ID to an authenticated FCM client
Implementations§
source§impl FcmRouter
impl FcmRouter
sourcepub async fn new(
settings: FcmSettings,
endpoint_url: Url,
http: Client,
metrics: Arc<StatsdClient>,
db: Box<dyn DbClient>,
) -> Result<Self, FcmError>
pub async fn new( settings: FcmSettings, endpoint_url: Url, http: Client, metrics: Arc<StatsdClient>, db: Box<dyn DbClient>, ) -> Result<Self, FcmError>
Create a new FcmRouter
sourceasync fn create_clients(
settings: &FcmSettings,
server_credentials: HashMap<String, FcmServerCredential>,
http: Client,
) -> Result<HashMap<String, FcmClient>>
async fn create_clients( settings: &FcmSettings, server_credentials: HashMap<String, FcmServerCredential>, http: Client, ) -> Result<HashMap<String, FcmClient>>
Create FCM clients for each application
sourcefn routing_info(
&self,
router_data: &HashMap<String, Value>,
uaid: &Uuid,
) -> Result<(String, String), ApiError>
fn routing_info( &self, router_data: &HashMap<String, Value>, uaid: &Uuid, ) -> Result<(String, String), ApiError>
Do the gauntlet check to get the routing credentials, these are the
sender/project ID, and the subscription specific user routing token.
FCM stores the values in the top hash as token
& app_id
, GCM stores them
in a sub-hash as creds.auth
and creds.senderID
.
If any of these error out, it’s probably because of a corrupted key.
Trait Implementations§
source§impl Router for FcmRouter
impl Router for FcmRouter
source§fn register(
&self,
router_data_input: &RouterDataInput,
app_id: &str,
) -> Result<HashMap<String, Value>, RouterError>
fn register( &self, router_data_input: &RouterDataInput, app_id: &str, ) -> Result<HashMap<String, Value>, RouterError>
Validate that the user can use this router, and return data to be stored in
the user’s
router_data
field.source§fn route_notification<'life0, 'life1, 'async_trait>(
&'life0 self,
notification: &'life1 Notification,
) -> Pin<Box<dyn Future<Output = Result<RouterResponse, ApiError>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn route_notification<'life0, 'life1, 'async_trait>(
&'life0 self,
notification: &'life1 Notification,
) -> Pin<Box<dyn Future<Output = Result<RouterResponse, ApiError>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Route a notification to the user
Auto Trait Implementations§
impl Freeze for FcmRouter
impl !RefUnwindSafe for FcmRouter
impl Send for FcmRouter
impl Sync for FcmRouter
impl Unpin for FcmRouter
impl !UnwindSafe for FcmRouter
Blanket Implementations§
§impl<T> AnySync for T
impl<T> AnySync for T
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more