pub struct VoiceUpload<'a> { /* private fields */ }Expand description
One voice note submitted through uploadvoice. A note of at most
VOICE_UPLOAD_CHUNK_BYTES uses a single request with the end flag set.
A larger note is sent as consecutive byte ranges (offset/length) under the
same client message ID; only the last range sets the end flag, and later
ranges carry a server message ID returned for an earlier range. Each range
is submitted once: an error after any submission is an uncertain outcome.
Implementations§
Source§impl<'a> VoiceUpload<'a>
impl<'a> VoiceUpload<'a>
pub fn new( destination: &'a str, client_id: &'a str, created_at: u32, duration_ms: u32, encoded: &'a [u8], ) -> Result<Self>
Sourcepub fn request_count(&self) -> usize
pub fn request_count(&self) -> usize
Number of requests needed for the whole note.
Sourcepub fn is_final(&self) -> bool
pub fn is_final(&self) -> bool
Whether the next request carries the last range and the end flag.
Sourcepub fn request(&self, state: &AccountState) -> Result<Vec<u8>>
pub fn request(&self, state: &AccountState) -> Result<Vec<u8>>
Build the request for the next unsent range.
Sourcepub fn accept_reply(&mut self, input: &[u8]) -> Result<Option<MediaSendResult>>
pub fn accept_reply(&mut self, input: &[u8]) -> Result<Option<MediaSendResult>>
Apply the reply for the request built last. Returns the note’s result
after the final range, or None when the next range must be sent. A
rejection after an earlier range was accepted needs review, because the
server already holds part of the note under this client message ID.