pub struct PushOptions { /* private fields */ }Expand description
Validated options an ExpoPushSender is built from.
Construct these with PushOptions::new in code, or with
PushOptions::from_config from a loaded PushConfig. Both reject the
same invalid values, so a bad endpoint or batch size fails at startup rather
than on the first notification.
Implementations§
Source§impl PushOptions
impl PushOptions
Sourcepub fn new(endpoint: impl Into<String>) -> Result<Self, PushOptionsError>
pub fn new(endpoint: impl Into<String>) -> Result<Self, PushOptionsError>
Creates options for a full push send endpoint URL.
Sourcepub fn from_config(config: &PushConfig) -> Result<Self, PushOptionsError>
pub fn from_config(config: &PushConfig) -> Result<Self, PushOptionsError>
Converts a loaded configuration section into validated options.
An empty access_token means the project does not enforce push
security, so no Authorization header is sent.
Sourcepub fn with_access_token(
self,
access_token: impl Into<String>,
) -> Result<Self, PushOptionsError>
pub fn with_access_token( self, access_token: impl Into<String>, ) -> Result<Self, PushOptionsError>
Sets the bearer token sent with every push request.
An empty or whitespace-only token is rejected; omit the call instead.
Sourcepub fn with_batch_size(
self,
batch_size: usize,
) -> Result<Self, PushOptionsError>
pub fn with_batch_size( self, batch_size: usize, ) -> Result<Self, PushOptionsError>
Sets how many notifications are sent in one upstream request.
Sourcepub fn with_request_timeout(
self,
request_timeout: Duration,
) -> Result<Self, PushOptionsError>
pub fn with_request_timeout( self, request_timeout: Duration, ) -> Result<Self, PushOptionsError>
Sets the timeout applied to each upstream request.
Sourcepub fn receipts_endpoint(&self) -> &str
pub fn receipts_endpoint(&self) -> &str
Returns the receipt endpoint derived next to the send endpoint.
Sourcepub fn access_token(&self) -> Option<&str>
pub fn access_token(&self) -> Option<&str>
Returns the access token, if one is configured.
Sourcepub const fn batch_size(&self) -> usize
pub const fn batch_size(&self) -> usize
Returns the number of notifications sent in one upstream request.
Sourcepub const fn request_timeout(&self) -> Duration
pub const fn request_timeout(&self) -> Duration
Returns the per-request timeout.