Struct rman::File

source ·
pub struct File {
    pub id: i64,
    pub name: String,
    pub permissions: u8,
    pub size: u32,
    pub path: String,
    pub symlink: String,
    pub tags: Vec<String>,
    /* private fields */
}
Expand description

Single file object.

Represents a file and it’s properties that can be downloaded and written to a file system.

Fields§

§id: i64

Id of the file.

§name: String

File name.

§permissions: u8

Permissions for the given file.

§size: u32

Size of the file entry in bytes.

§path: String

Absolute path to the file, where root is one of the directory entries.

§symlink: String

Symbolic link of the file.

§tags: Vec<String>

A vector of applicable tags.

Implementations§

source§

impl File

source

pub fn parse( file: &FileEntry, tag_entries: &HashMap<u8, String>, directories: &HashMap<i64, (String, i64)>, chunk_entries: &HashMap<i64, (i64, u32, u32, u32)> ) -> Result<Self>

Parses FileEntry into a File object.

First parameter is a FileEntry that is parsed into a File, the other three are HashMaps used for fast lookups for the required data.

Here is how they are structured:

Errors

If a directory with provided id or parent id does not exist within the directories HashMap, or if a chunk with chunk id does not exist within the chunk_entries HashMap, the error FileParseError is returned.

source§

impl File

source

pub async fn download<W: Write + Send, U: IntoUrl + Send>( &self, writer: W, bundle_url: U ) -> Result<()>

Function to download the associated file contents.

This is done by looping through all of the chunks of this file, and for each loop:

  • get the bundle id it belongs to, and convert it to hexadecimal value with a fixed size of 16 (if the length is less than 16, zeros are padded to the left).
  • download the chunk from the url using the range header
  • decompress the chunk
  • write chunk.
Errors

If downloading fails, the error ReqwestError is returned.

If converting uncompressed_size to usize fails, the error ConversionFailure is returned.

If zstd decompression fails, the error ZstdDecompressError is returned.

If writing to io stream fails, the error IoError is returned.

Examples

See downloading a file.

Trait Implementations§

source§

impl Clone for File

source§

fn clone(&self) -> File

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for File

source§

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

Formats the value using the given formatter. Read more
source§

impl Default for File

source§

fn default() -> File

Returns the “default value” for a type. Read more
source§

impl PartialEq<File> for File

source§

fn eq(&self, other: &File) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for File

source§

impl StructuralEq for File

source§

impl StructuralPartialEq for File

Auto Trait Implementations§

§

impl RefUnwindSafe for File

§

impl Send for File

§

impl Sync for File

§

impl Unpin for File

§

impl UnwindSafe for File

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

const: unstable · 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 Twhere U: From<T>,

const: unstable · 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
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