[][src]Struct libojo::File

pub struct File { /* fields omitted */ }

A File is a special case of a Graggle, in which there is just a linear order.

This struct offers convenient (read-only) access to a File, allowing the contents and ids of nodes to be access by indexing.

The most convenient way to get a File is through Repo::file, but they can also be built from raw bytes (using File::from_bytes).

Methods

impl File[src]

pub fn from_bytes(bytes: &[u8]) -> File[src]

Creates a File from the raw bytes, by dividing them into lines.

The NodeIds will be synthesized: they will have empty PatchIds, and their node indices will be consecutive, starting from zero.

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

How many nodes does this file have?

Currently, "nodes" is synonymous with "lines", but that may not necessarily be the case in the future (for example, we could diff files based on words instead of lines).

pub fn node(&self, idx: usize) -> &[u8][src]

Gets the contents of the node at the given index. This includes the \n character, if there was one.

pub fn node_id(&self, idx: usize) -> &NodeId[src]

Gets the id of the node at the given index.

pub fn as_bytes(&self) -> &[u8][src]

Gets the whole file, as an array of bytes.

Trait Implementations

impl PartialEq<File> for File[src]

impl Clone for File[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Eq for File[src]

impl Debug for File[src]

Auto Trait Implementations

impl Send for File

impl Sync for File

Blanket Implementations

impl<T> From for T[src]

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

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

type Owned = T

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

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

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

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

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

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

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

impl<T> Same for T

type Output = T

Should always be Self