Skip to main content

Part

Struct Part 

Source
pub(crate) struct Part {
    pub start: u64,
    pub end: Option<u64>,
    pub saved: u64,
    pub connection: Option<Live>,
    pub failures: u32,
    pub retry_at: Option<Instant>,
}
Expand description

A stretch of the file, and how much of it is saved.

Fields§

§start: u64§end: Option<u64>

Where the next part starts; None for a part that runs to the end of the file.

§saved: u64

The bytes saved from start on.

§connection: Option<Live>

The connection fetching it, unless it is paused, waiting to retry, or done.

§failures: u32

The failures in a row that may pass, since it last received data.

§retry_at: Option<Instant>

When to try it again, after such a failure.

Implementations§

Source§

impl Part

Source

pub(crate) fn whole() -> Self

The whole file, as one connection fetches it.

Source

pub(crate) fn position(&self) -> u64

Where in the file its next byte goes.

Source

pub(crate) fn rest(&self) -> ByteRange

What is left of it to ask for.

Source

pub(crate) fn room(&self) -> Option<u64>

How many more bytes it takes, when it ends before the file does.

Source

pub(crate) fn is_complete(&self, total: Option<u64>) -> bool

Whether all of it is saved, given the whole file’s length when known.

Source

pub(crate) fn hang_up(&mut self) -> Option<File>

Stops its connection, counting everything it wrote, and gives the file it was writing, if the server had answered.

Trait Implementations§

Source§

impl Debug for Part

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Part

§

impl RefUnwindSafe for Part

§

impl Send for Part

§

impl Sync for Part

§

impl Unpin for Part

§

impl UnsafeUnpin for Part

§

impl UnwindSafe for Part

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.