Skip to main content

DocumentChannel

Struct DocumentChannel 

Source
pub struct DocumentChannel { /* private fields */ }
Expand description

A live connection to a document’s real-time channel, joined via crate::ScribeClient::open_document_channel.

Progress on formats that were already converting (or complete) when the channel was joined arrives as ChannelEvents from Self::next_event just like anything started with Self::start_conversion after joining.

Heartbeats keep the connection open only while a call on this channel is waiting, so keep calling Self::next_event during a conversion. The connection can still be lost, for example to a network failure or a server restart. A conversion carries on without it: open a new channel on the same document, and don’t upload it again.

Implementations§

Source§

impl DocumentChannel

Source

pub async fn start_conversion( &mut self, format: OutputFormat, password: Option<&str>, ) -> Result<String, ScribeError>

Starts converting the joined document to format, using its current settings. If that format is already complete, the server returns its existing output id instead of starting a new conversion. Returns immediately with the output id; progress arrives via subsequent Self::next_event calls.

§Errors

Returns ScribeError::NotFound/ScribeError::Forbidden if the document doesn’t exist or isn’t owned by the caller, ScribeError::ConversionInProgress if any non-preview conversion of the document is running, including that format and the html_stream that creating the document started (wait for its ChannelEvent::ConversionComplete, then call this again), ScribeError::RateLimited if too many conversions were started too quickly, ScribeError::NeedsPurchase if the account is out of page credits, or ScribeError::PasswordRequired if the document is a protected file and password was None or wrong.

password unlocks a password-protected document. It’s stored against the document, so later conversions of other formats don’t need it again. A wrong password isn’t detected here — the server accepts it, the converter rejects it, and an ChannelEvent::Error with reason invalid_password arrives from Self::next_event; retry this call with a corrected password.

Source

pub async fn next_event(&mut self) -> Result<ChannelEvent, ScribeError>

§Errors

Returns ScribeError::WebSocket if the connection fails, or ScribeError::ChannelClosed if it closes before another event arrives.

Source

pub async fn close(self) -> Result<(), ScribeError>

Closes the connection. One that’s already closed or lost is fine, since that’s what this is for.

§Errors

Returns ScribeError::WebSocket if closing the connection fails with it still open.

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