Skip to main content

Editor

Trait Editor 

Source
pub trait Editor<P: Marshallable>: Deref<Target = P> + DerefMut<Target = P> {
    // Required methods
    fn orig_content(&self) -> Option<&[u8]>;
    fn updated_content(&self) -> Option<Vec<u8>>;
    fn rewritten_content(&self) -> Option<&[u8]>;
    fn is_generated(&self) -> bool;
    fn commit(&mut self) -> Result<Vec<PathBuf>, EditorError<P::Error>>;
    fn revert(&mut self) -> Result<(), EditorError<P::Error>>;

    // Provided method
    fn has_changed(&self) -> bool { ... }
}
Expand description

An editor for a file

Required Methods§

Source

fn orig_content(&self) -> Option<&[u8]>

The original content, if any - without reformatting

Source

fn updated_content(&self) -> Option<Vec<u8>>

The updated content, if any

Source

fn rewritten_content(&self) -> Option<&[u8]>

The original content, but rewritten with our parser/serializer

Source

fn is_generated(&self) -> bool

Check if the file is generated

Source

fn commit(&mut self) -> Result<Vec<PathBuf>, EditorError<P::Error>>

Commit the changes

§Returns

A list of paths that were changed

Source

fn revert(&mut self) -> Result<(), EditorError<P::Error>>

Revert the changes to the original state

§Errors

Returns an error if reverting fails (e.g., I/O error, parsing error)

Provided Methods§

Source

fn has_changed(&self) -> bool

Whether the file has changed

Implementors§