Skip to main content

ScribeClient

Struct ScribeClient 

Source
pub struct ScribeClient { /* private fields */ }

Implementations§

Source§

impl ScribeClient

Source

pub fn new( http: Client, base_url: Url, client_id: impl Into<String>, tokens: TokenSet, ) -> Self

Source

pub async fn current_tokens(&self) -> TokenSet

Returns a snapshot of the current token set. Useful for persisting the session after the client has auto-refreshed it.

Source

pub async fn create_document( &self, source: DocumentSource, password: Option<&str>, ) -> Result<CreatedDocument, ScribeError>

Creates a document from source.

§Errors

Returns ScribeError::Http/ScribeError::Api if the request fails or the server rejects it. password unlocks a password-protected source file. Supplying it up front saves a round trip when the caller already knows the document is protected; otherwise leave it None and handle the password_required signal on the document channel.

Source

pub async fn list_documents(&self) -> Result<DocumentList, ScribeError>

Lists every document owned by the current user, each with its outputs embedded (so this alone is enough to show a document list with per-document conversion status, no follow-up list_outputs calls needed).

§Errors

Returns ScribeError::Http/ScribeError::Api on request failure.

Source

pub async fn trash_document(&self, document_id: &str) -> Result<(), ScribeError>

Moves a document to the trash. It’s permanently deleted 7 days later, or sooner per the owner’s org retention policy, unless recovered first with recover_document.

§Errors

Returns ScribeError::NotFound/ScribeError::Forbidden if the document doesn’t exist or isn’t owned by the caller, or ScribeError::Http/ScribeError::Api on other request failures.

Source

pub async fn delete_document_permanently( &self, document_id: &str, ) -> Result<(), ScribeError>

Permanently deletes a document and all of its outputs. The document must already be in the trash (see trash_document).

§Errors

Returns ScribeError::NotFound/ScribeError::Forbidden if the document doesn’t exist or isn’t owned by the caller, ScribeError::NotTrashed if it hasn’t been moved to the trash yet, or ScribeError::Http/ScribeError::Api on other request failures.

Source

pub async fn recover_document( &self, document_id: &str, ) -> Result<(), ScribeError>

Restores a trashed document, clearing its trash state.

§Errors

Returns ScribeError::NotFound/ScribeError::Forbidden if the document doesn’t exist or isn’t owned by the caller, or ScribeError::Http/ScribeError::Api on other request failures.

Source

pub async fn list_trashed_documents( &self, ) -> Result<Vec<TrashedDocument>, ScribeError>

Lists the caller’s trashed documents, most recently trashed first.

§Errors

Returns ScribeError::Http/ScribeError::Api on request failure.

Source

pub async fn submit_document_feedback( &self, document_id: &str, comment: &str, ) -> Result<(), ScribeError>

Submits a document for human review, attaching comment as the reason / description of the problem.

Source

pub async fn open_document_channel( &self, document_id: &str, ) -> Result<DocumentChannel, ScribeError>

Opens a real-time channel for document_id, subscribing to progress on whatever formats are already in progress (or their incomplete parent formats) and allowing new conversions to be started with DocumentChannel::start_conversion. This is the only way to start a conversion for a format other than the html_stream preview create_document already starts — it’s no longer possible over plain REST, so the server can guarantee it’s subscribed to whatever it just started converting.

§Errors

Returns ScribeError::NotFound/ScribeError::Forbidden if the document doesn’t exist or isn’t owned by the caller, or ScribeError::WebSocket if the connection fails.

Source

pub async fn list_outputs( &self, document_id: &str, ) -> Result<OutputList, ScribeError>

§Errors

Returns ScribeError::NotFound/ScribeError::Forbidden if the document doesn’t exist or isn’t owned by the caller, or ScribeError::Http/ScribeError::Api on other request failures.

Source

pub async fn download_output( &self, document_id: &str, format: OutputFormat, ) -> Result<Download, ScribeError>

§Errors

Returns ScribeError::ConversionNotComplete if that format hasn’t finished converting yet, ScribeError::NotFound/ScribeError::Forbidden if the document doesn’t exist or isn’t owned by the caller, or ScribeError::Http/ScribeError::Api on other request failures.

Source

pub async fn download_url( &self, document_id: &str, format: OutputFormat, ) -> Result<Option<String>, ScribeError>

Where the file can be fetched from directly, when the server answers with a redirect rather than the bytes.

The API redirects to storage by default, and that URL carries a real Content-Length and accepts range requests, which is what a media player needs to start before the whole file has arrived and to seek afterwards. None means this server sends the file itself, so the caller has to download it first.

§Errors

The same as download_output.

Source

pub async fn download_output_with_progress<F>( &self, document_id: &str, format: OutputFormat, on_progress: F, ) -> Result<Download, ScribeError>
where F: FnMut(u64, Option<u64>) + Send,

As download_output, reporting bytes received as they arrive: (downloaded, total), where total is None when the server doesn’t say how big the file is.

Audio of a long document is tens of megabytes, and the whole download used to be one silent wait.

§Errors

The same as download_output.

Source

pub async fn get_settings( &self, document_id: &str, ) -> Result<Settings, ScribeError>

§Errors

Returns ScribeError::NotFound/ScribeError::Forbidden if the document doesn’t exist or isn’t owned by the caller, or ScribeError::Http/ScribeError::Api on other request failures.

Source

pub async fn update_settings( &self, document_id: &str, update: &SettingsUpdate, ) -> Result<Settings, ScribeError>

§Errors

Returns ScribeError::NotFound/ScribeError::Forbidden if the document doesn’t exist or isn’t owned by the caller, or ScribeError::Http/ScribeError::Api on other request failures (including validation errors on the settings themselves).

Source

pub async fn rename_document( &self, document_id: &str, title: &str, ) -> Result<DocumentSummary, ScribeError>

Changes a document’s title.

Titles start life as the uploaded file name, which for a photo or a share-sheet import is something like “IMG_6746783276432”, so this is how a caller fixes one after the fact. Returns the document as the list endpoint describes it, so a caller can refresh its row from the result.

§Errors

Returns ScribeError::NotFound/ScribeError::Forbidden if the document doesn’t exist or isn’t owned by the caller, or ScribeError::Api if the title is rejected (it may not be blank and is capped at 255 characters).

Source

pub async fn browser_entry_url( &self, return_to_path: &str, ) -> Result<String, ScribeError>

A URL that signs the system browser in as this client’s user, then lands on return_to_path.

The app and the browser do not share a session, so a bare link to a settings page would greet the user with a login form. This hands the app’s access token to /auth/browser_from_oauth, which trades it for a browser session and redirects.

Refreshes the token first when it is near expiry. The server rejects a stale one with a “Failed to log in” page, and that is the page the user would land on.

§Errors

Returns ScribeError::InvalidGrant if the token has expired and cannot be refreshed, or ScribeError::Http if the refresh request fails.

Source

pub async fn delete_account_url(&self) -> Result<String, ScribeError>

The account-deletion page, signed in, for an app that lets users start deleting their account from inside it.

§Errors

As for ScribeClient::browser_entry_url.

Source

pub async fn default_settings(&self) -> Result<Settings, ScribeError>

The caller’s default conversion settings, which every new document’s settings are seeded from.

Account-scoped, so there is no id: a user has exactly one set, and the server creates it on first read rather than returning a 404.

§Errors

Returns ScribeError::Http/ScribeError::Api on request failure.

Source

pub async fn update_default_settings( &self, update: &SettingsUpdate, ) -> Result<Settings, ScribeError>

Updates the caller’s default conversion settings. Partial: fields left None on update are not sent, so they keep their current value.

Changing these does not touch documents that already exist.

§Errors

Returns ScribeError::Http/ScribeError::Api on request failure, including validation errors on the settings themselves.

Source

pub async fn register_device( &self, token: &str, platform: &str, ) -> Result<(), ScribeError>

Registers token (the hex-encoded APNs device token) so the server can send this device push notifications. Registration is an upsert — re-registering the same token re-points it at the current user (e.g. after signing out and into a different account on the same device).

§Errors

Returns ScribeError::Http/ScribeError::Api on request failure.

Source

pub async fn unregister_device(&self, token: &str) -> Result<(), ScribeError>

Unregisters token, e.g. on sign-out, so this device stops receiving push.

§Errors

Returns ScribeError::Http/ScribeError::Api on request failure.

Source

pub async fn get_notification_settings( &self, ) -> Result<NotificationSettings, ScribeError>

§Errors

Returns ScribeError::Http/ScribeError::Api on request failure.

Source

pub async fn update_notification_settings( &self, push_notify_when_complete: bool, ) -> Result<NotificationSettings, ScribeError>

§Errors

Returns ScribeError::Http/ScribeError::Api on request failure.

Source

pub async fn get_account_info(&self) -> Result<AccountInfo, ScribeError>

§Errors

Returns ScribeError::Http/ScribeError::Api on request failure.

Source

pub async fn billing(&self) -> Result<BillingStatus, ScribeError>

The pages the account has left and its active subscription, if any.

§Errors

Returns ScribeError::Http/ScribeError::Api on request failure.

Source

pub async fn app_store_products( &self, ) -> Result<Vec<AppStoreProduct>, ScribeError>

Lists the App Store products on sale, in the order to show them.

§Errors

Returns ScribeError::Http/ScribeError::Api on request failure.

Source

pub async fn submit_app_store_transaction( &self, signed_transaction: &str, ) -> Result<BillingStatus, ScribeError>

Credits a completed App Store purchase to the account. signed_transaction is Transaction.jwsRepresentation from StoreKit 2. Reporting the same transaction again is harmless, so finish the transaction in StoreKit only once this succeeds. Returns the billing status afterwards.

§Errors

Returns ScribeError::Api with code other_account if the purchase was made while signed in to a different Scribe account, or invalid_transaction if the server couldn’t verify it.

Source

pub async fn languages(&self) -> Result<Vec<Language>, ScribeError>

§Errors

Returns ScribeError::Http/ScribeError::Api on request failure.

Source

pub async fn dialects( &self, ) -> Result<HashMap<String, Vec<Dialect>>, ScribeError>

§Errors

Returns ScribeError::Http/ScribeError::Api on request failure.

Source

pub async fn braille_tables(&self) -> Result<Vec<BrailleTable>, ScribeError>

§Errors

Returns ScribeError::Http/ScribeError::Api on request failure.

Source

pub async fn voices(&self) -> Result<HashMap<String, Vec<Voice>>, ScribeError>

§Errors

Returns ScribeError::Http/ScribeError::Api on request failure.

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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: Sized + 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: Sized + 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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