Struct radicle_surf::file_system::directory::File[][src]

pub struct File {
    pub contents: Vec<u8>,
    // some fields omitted
}

A File consists of its file contents (a Vec of bytes).

The Debug instance of File will show the first few bytes of the file and its size.

Fields

contents: Vec<u8>

The contents of a File as a vector of bytes.

Implementations

impl File[src]

pub fn new(contents: &[u8]) -> Self[src]

Create a new File with the contents provided.

pub fn size(&self) -> usize[src]

Get the size of the File corresponding to the number of bytes in the file contents.

Examples

use radicle_surf::file_system::File;

let file = File::new(b"pub mod diff;\npub mod file_system;\npub mod vcs;\npub use crate::vcs::git;\n");

assert_eq!(file.size(), 73);

pub fn checksum(&self) -> u64[src]

Get the hash of the File corresponding to the contents of the file.

Examples

use radicle_surf::file_system::File;

let file = File::new(
    b"pub mod diff;\npub mod file_system;\npub mod vcs;\npub use crate::vcs::git;\n",
);

assert_eq!(file.checksum(), 8457766712413557403);

Trait Implementations

impl Clone for File[src]

impl Debug for File[src]

impl Eq for File[src]

impl PartialEq<File> for File[src]

impl StructuralEq for File[src]

impl StructuralPartialEq for File[src]

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Conv for T

impl<T> Conv for T

impl<T> FmtForward for T

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pipe for T where
    T: ?Sized

impl<T> Pipe for T

impl<T> PipeAsRef for T

impl<T> PipeBorrow for T

impl<T> PipeDeref for T

impl<T> PipeRef for T

impl<T> Tap for T

impl<T> Tap for T

impl<T, U> TapAsRef<U> for T where
    U: ?Sized

impl<T, U> TapBorrow<U> for T where
    U: ?Sized

impl<T> TapDeref for T

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> TryConv for T

impl<T> TryConv for T

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.