pub struct ServerState<S, A, G, D>{
pub config: Config,
pub index_db: Arc<Mutex<ServerV4>>,
pub stripe_client: S,
pub google_play_client: G,
pub app_store_client: A,
pub document_service: D,
}
Fields§
§config: Config
§index_db: Arc<Mutex<ServerV4>>
§stripe_client: S
§google_play_client: G
§app_store_client: A
§document_service: D
Implementations§
Source§impl<S, A, G, D> ServerState<S, A, G, D>
impl<S, A, G, D> ServerState<S, A, G, D>
Sourcepub async fn new_account(
&self,
context: RequestContext<NewAccountRequest>,
) -> Result<NewAccountResponse, ServerError<NewAccountError>>
pub async fn new_account( &self, context: RequestContext<NewAccountRequest>, ) -> Result<NewAccountResponse, ServerError<NewAccountError>>
Create a new account given a username, public_key, and root folder. Checks that username is valid, and that username, public_key and root_folder are new. Inserts all of these values into their respective keys along with the default free account tier size
pub async fn get_public_key( &self, context: RequestContext<GetPublicKeyRequest>, ) -> Result<GetPublicKeyResponse, ServerError<GetPublicKeyError>>
pub fn public_key_from_username( &self, username: &str, ) -> Result<GetPublicKeyResponse, ServerError<GetPublicKeyError>>
pub async fn get_username( &self, context: RequestContext<GetUsernameRequest>, ) -> Result<GetUsernameResponse, ServerError<GetUsernameError>>
pub fn username_from_public_key( &self, key: PublicKey, ) -> Result<GetUsernameResponse, ServerError<GetUsernameError>>
pub async fn get_usage( &self, context: RequestContext<GetUsageRequest>, ) -> Result<GetUsageResponse, ServerError<GetUsageError>>
pub fn get_usage_helper<T>(
tree: &mut LazyTree<T>,
sizes: &HashMap<Uuid, u64>,
) -> Result<Vec<FileUsage>, ServerError<GetUsageHelperError>>where
T: TreeLike,
pub fn get_cap( db: &ServerDb, public_key: &PublicKey, ) -> Result<u64, ServerError<GetUsageHelperError>>
pub async fn delete_account( &self, context: RequestContext<DeleteAccountRequest>, ) -> Result<(), ServerError<DeleteAccountError>>
pub async fn admin_disappear_account( &self, context: RequestContext<AdminDisappearAccountRequest>, ) -> Result<(), ServerError<AdminDisappearAccountError>>
pub async fn admin_list_users( &self, context: RequestContext<AdminListUsersRequest>, ) -> Result<AdminListUsersResponse, ServerError<AdminListUsersError>>
pub async fn admin_get_account_info( &self, context: RequestContext<AdminGetAccountInfoRequest>, ) -> Result<AdminGetAccountInfoResponse, ServerError<AdminGetAccountInfoError>>
pub async fn delete_account_helper( &self, public_key: &PublicKey, free_username: bool, ) -> Result<(), ServerError<DeleteAccountHelperError>>
pub fn is_admin<E: Debug>( db: &ServerDb, public_key: &PublicKey, admins: &HashSet<Username>, ) -> Result<bool, ServerError<E>>
Source§impl<S, A, G, D> ServerState<S, A, G, D>
impl<S, A, G, D> ServerState<S, A, G, D>
pub fn get_public_key_from_tx( &self, trans: &TransactionInfo, ) -> Result<PublicKey, ServerError<AppStoreNotificationError>>
pub async fn verify_details( client: &A, config: &AppleConfig, app_account_token: &str, original_transaction_id: &str, ) -> Result<(UnixTimeMillis, AppStoreAccountState), ServerError<UpgradeAccountAppStoreError>>
pub fn decode_verify_notification( config: &AppleConfig, request_body: &Bytes, ) -> Result<NotificationResponseBody, ServerError<AppStoreNotificationError>>
pub fn decode_verify_transaction( config: &AppleConfig, encoded_transaction: &str, ) -> Result<TransactionInfo, ServerError<AppStoreNotificationError>>
Source§impl<S, A, G, D> ServerState<S, A, G, D>
impl<S, A, G, D> ServerState<S, A, G, D>
pub async fn upgrade_account_app_store( &self, context: RequestContext<UpgradeAccountAppStoreRequest>, ) -> Result<UpgradeAccountAppStoreResponse, ServerError<UpgradeAccountAppStoreError>>
pub async fn upgrade_account_google_play( &self, context: RequestContext<UpgradeAccountGooglePlayRequest>, ) -> Result<UpgradeAccountGooglePlayResponse, ServerError<UpgradeAccountGooglePlayError>>
pub async fn upgrade_account_stripe( &self, context: RequestContext<UpgradeAccountStripeRequest>, ) -> Result<UpgradeAccountStripeResponse, ServerError<UpgradeAccountStripeError>>
pub async fn get_subscription_info( &self, context: RequestContext<GetSubscriptionInfoRequest>, ) -> Result<GetSubscriptionInfoResponse, ServerError<GetSubscriptionInfoError>>
pub async fn cancel_subscription( &self, context: RequestContext<CancelSubscriptionRequest>, ) -> Result<CancelSubscriptionResponse, ServerError<CancelSubscriptionError>>
pub async fn admin_set_user_tier( &self, context: RequestContext<AdminSetUserTierRequest>, ) -> Result<AdminSetUserTierResponse, ServerError<AdminSetUserTierError>>
pub async fn stripe_webhooks( &self, request_body: Bytes, stripe_sig: HeaderValue, ) -> Result<(), ServerError<StripeWebhookError>>
pub async fn google_play_notification_webhooks( &self, request_body: Bytes, query_parameters: HashMap<String, String>, ) -> Result<(), ServerError<GooglePlayWebhookError>>
pub async fn app_store_notification_webhook( &self, body: Bytes, ) -> Result<(), ServerError<AppStoreNotificationError>>
Source§impl<S, A, G, D> ServerState<S, A, G, D>
impl<S, A, G, D> ServerState<S, A, G, D>
pub fn get_public_key_from_subnotif( &self, sub_notif: &SubscriptionNotification, subscription: &SubscriptionPurchase, notification_type: &NotificationType, ) -> Result<PublicKey, ServerError<GooglePlayWebhookError>>
pub fn get_subscription_period_end( subscription: &SubscriptionPurchase, notification_type: &NotificationType, public_key: PublicKey, ) -> Result<UnixTimeMillis, ServerError<GooglePlayWebhookError>>
pub async fn verify_request_and_get_notification( &self, request_body: Bytes, query_parameters: HashMap<String, String>, ) -> Result<DeveloperNotification, ServerError<GooglePlayWebhookError>>
Source§impl<S, A, G, D> ServerState<S, A, G, D>
impl<S, A, G, D> ServerState<S, A, G, D>
pub async fn create_subscription( &self, public_key: &PublicKey, account_tier: &StripeAccountTier, maybe_user_info: Option<StripeUserInfo>, ) -> Result<StripeUserInfo, ServerError<UpgradeAccountStripeError>>
pub fn get_public_key_from_invoice( &self, invoice: &Invoice, ) -> Result<PublicKey, ServerError<StripeWebhookError>>
pub fn verify_request_and_get_event( &self, request_body: &Bytes, stripe_sig: HeaderValue, ) -> Result<Event, ServerError<StripeWebhookError>>
Source§impl<S, A, G, D> ServerState<S, A, G, D>
impl<S, A, G, D> ServerState<S, A, G, D>
pub async fn upsert_file_metadata( &self, context: RequestContext<UpsertRequest>, ) -> Result<(), ServerError<UpsertError>>
pub async fn change_doc( &self, context: RequestContext<ChangeDocRequest>, ) -> Result<(), ServerError<ChangeDocError>>
pub async fn get_document( &self, context: RequestContext<GetDocRequest>, ) -> Result<GetDocumentResponse, ServerError<GetDocumentError>>
pub async fn get_file_ids( &self, context: RequestContext<GetFileIdsRequest>, ) -> Result<GetFileIdsResponse, ServerError<GetFileIdsError>>
pub async fn get_updates( &self, context: RequestContext<GetUpdatesRequest>, ) -> Result<GetUpdatesResponse, ServerError<GetUpdatesError>>
pub async fn admin_disappear_file( &self, context: RequestContext<AdminDisappearFileRequest>, ) -> Result<(), ServerError<AdminDisappearFileError>>
pub async fn admin_validate_account( &self, context: RequestContext<AdminValidateAccountRequest>, ) -> Result<AdminValidateAccount, ServerError<AdminValidateAccountError>>
pub fn validate_account_helper( &self, db: &mut ServerDb, owner: Owner, ) -> SharedResult<AdminValidateAccount>
pub async fn admin_validate_server( &self, context: RequestContext<AdminValidateServerRequest>, ) -> Result<AdminValidateServer, ServerError<AdminValidateServerError>>
pub async fn admin_file_info( &self, context: RequestContext<AdminFileInfoRequest>, ) -> Result<AdminFileInfoResponse, ServerError<AdminFileInfoError>>
pub async fn admin_rebuild_index( &self, context: RequestContext<AdminRebuildIndexRequest>, ) -> Result<(), ServerError<AdminRebuildIndexError>>
Source§impl<S, A, G, D> ServerState<S, A, G, D>
impl<S, A, G, D> ServerState<S, A, G, D>
pub fn start_metrics_worker(&self)
pub async fn start_metrics_loop(self) -> Result<(), ServerError<MetricsError>>
pub fn get_user_billing_info( db: &ServerDb, owner: &Owner, ) -> Result<SubscriptionProfile, ServerError<MetricsError>>
pub fn get_user_info( db: &mut ServerDb, owner: Owner, ) -> Result<Option<UserInfo>, ServerError<MetricsError>>
Trait Implementations§
Source§impl<S, A, G, D> Clone for ServerState<S, A, G, D>where
S: StripeClient + Clone,
A: AppStoreClient + Clone,
G: GooglePlayClient + Clone,
D: DocumentService + Clone,
impl<S, A, G, D> Clone for ServerState<S, A, G, D>where
S: StripeClient + Clone,
A: AppStoreClient + Clone,
G: GooglePlayClient + Clone,
D: DocumentService + Clone,
Source§fn clone(&self) -> ServerState<S, A, G, D>
fn clone(&self) -> ServerState<S, A, G, D>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl<S, A, G, D> Freeze for ServerState<S, A, G, D>
impl<S, A, G, D> RefUnwindSafe for ServerState<S, A, G, D>
impl<S, A, G, D> Send for ServerState<S, A, G, D>
impl<S, A, G, D> Sync for ServerState<S, A, G, D>
impl<S, A, G, D> Unpin for ServerState<S, A, G, D>
impl<S, A, G, D> UnwindSafe for ServerState<S, A, G, D>
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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