# Struct libfar::farlib::FarFile
[−] [src]

    pub struct FarFile {
        pub name: String,
        pub size: u32,
        pub data: Vec<u8>,
    }

Expand description

Struct containing a file, whether or not it’s in an archive. This should be used when creating a file from a buffer, or when getting files from an archive.

Should be created by calling `FarFile::new_from_archive` if extracting from an archive, or `FarFile::new_from_file` if reading from a buffer.

## Examples

    // buffer is a Vec<u8> containing the contents of a file
    // fileA_name is the name of the file
    use libfar::farlib::FarFile;
    let fileA = FarFile::new_from_file(fileA_name, buffer.len() as u32, buffer);

    // archive_buf is a Vec<u8> containing the contents of a .far file
    // fileB_name is the name of the file that we got from reading the manifest
    // fileB_size is the size of the file that we got from reading the manifest
    // fileB_offset is the offset of the file that we got from reading the manifest
    let fileB = FarFile::new_from_archive(fileB_name, fileB_size, fileB_offset, archive_buf);

## Fields

`name: String` `size: u32` `data: Vec<u8>`

## Implementations

[src]

### impl FarFile

[src]

#### pub fn new_from_archive(
name: String,
size: u32,
offset: u32,
original_file: &Vec<u8>
) -> FarFile

Creates a new FarFile struct from an offset, size, and archive buffer.

##### Examples

    // archive_buf is a Vec<u8> containing the contents of a .far file
    // file_name is the name of the file that we got from reading the manifest
    // file_size is the size of the file that we got from reading the manifest
    // file_offset is the offset of the file that we got from reading the manifest
    use libfar::farlib::FarFile;
    let file = FarFile::new_from_archive(file_name, file_size, file_offset, archive_buf);

[src]

#### pub fn new_from_file(name: String, size: u32, data: Vec<u8>) -> FarFile

Creates a new FarFile struct from a size, and data buffer.

##### Examples

    // buffer is a Vec<u8> containing the contents of a file
    // file_name is the name of the file
    use libfar::farlib::FarFile;
    let file = FarFile::new_from_file(file_name, buffer.len() as u32, buffer);

## Auto Trait Implementations

### impl RefUnwindSafe for FarFile

### impl Send for FarFile

### impl Sync for FarFile

### impl Unpin for FarFile

### impl UnwindSafe for FarFile

## Blanket Implementations

[src]

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

[src]

#### pub fn type_id(&self) -> TypeId

Gets the `TypeId` of `self`. Read more

[src]

### impl<T> Borrow<T> for T where
T: ?Sized,

[src]

#### pub fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more

[src]

### impl<T> BorrowMut<T> for T where
T: ?Sized,

[src]

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

Mutably borrows from an owned value. Read more

[src]

### impl<T> From<T> for T

[src]

#### pub fn from(t: T) -> T

Performs the conversion.

[src]

### impl<T, U> Into<U> for T where
U: From<T>,

[src]

#### pub fn into(self) -> U

Performs the conversion.

[src]

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

#### type Error = Infallible

The type returned in the event of a conversion error.

[src]

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

Performs the conversion.

[src]

### impl<T, U> TryInto<U> for T where
U: TryFrom<T>,

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

The type returned in the event of a conversion error.

[src]

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

Performs the conversion.