[][src]Trait superfusion::file::File

pub trait File {
    fn relation(&self) -> Vec<Relation>;
fn data(self) -> Vec<u8>;
fn modify_relation(self, from: &Index, to: &Index) -> Self
    where
        Self: Sized
; fn merge(self, other: Self) -> Result<Self, Error>
    where
        Self: Sized
, { ... } }

Representing a file type within the project.

Note that at this step, the file's data should already be loaded into memory.
The workspace will be calling this trait to ask for various modification and its job is to provide back the correct version.

Required methods

fn relation(&self) -> Vec<Relation>

Return a "relationship" to another files.

This is use to determine whether its content should be modify when the other index is renamed.

fn data(self) -> Vec<u8>

Return the file's data.

Note that the file's data should already be stored inside this struct and this method simply return that data.
This is to allow transforming relationship via modify_relation() method without rewriting the file.

fn modify_relation(self, from: &Index, to: &Index) -> Self where
    Self: Sized

Get call when an Index that have relation to this file get renamed.
This method should act appropriately and rename the reference to that index within this file as well.

Loading content...

Provided methods

fn merge(self, other: Self) -> Result<Self, Error> where
    Self: Sized

Define how the file can be merge together.

Note: other will always be newer than self so you should prioritize other more than self.

Loading content...

Implementors

Loading content...