Skip to main content

FormatAdapter

Trait FormatAdapter 

Source
pub trait FormatAdapter {
    // Required methods
    fn edit_text(
        &self,
        text: &str,
        pointer: &str,
        value: &str,
    ) -> Result<String>;
    fn read_text(&self, text: &str, pointer: &str) -> Result<String>;

    // Provided methods
    fn read(&self, file: &Path, pointer: &str) -> Result<String> { ... }
    fn write(
        &self,
        file: &Path,
        pointer: &str,
        new_value: &str,
        dry_run: bool,
    ) -> Result<()> { ... }
}
Expand description

A format-preserving version-value adapter.

Required Methods§

Source

fn edit_text(&self, text: &str, pointer: &str, value: &str) -> Result<String>

Produce updated text without touching the filesystem.

Source

fn read_text(&self, text: &str, pointer: &str) -> Result<String>

Read a selected string from in-memory text.

Provided Methods§

Source

fn read(&self, file: &Path, pointer: &str) -> Result<String>

Read a string value selected by pointer.

Source

fn write( &self, file: &Path, pointer: &str, new_value: &str, dry_run: bool, ) -> Result<()>

Write a selected value unless dry_run is enabled.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§