[−][src]Struct libquilt::File
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 NodeId
s will be synthesized: they will have empty PatchId
s, 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 Clone for File
[src]
fn clone(&self) -> 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 PartialEq<File> for File
[src]
impl Debug for File
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Same for T
type Output = T
Should always be Self