pub struct ConfigFile { /* private fields */ }Expand description
The config file a tool edits.
Implementations§
Source§impl ConfigFile
impl ConfigFile
pub fn new(path: impl Into<PathBuf>, check: Arc<dyn ConfigCheck>) -> Self
pub fn path(&self) -> &Path
Sourcepub fn validate(&self, content: &str) -> Result<(), String>
pub fn validate(&self, content: &str) -> Result<(), String>
The host’s check of a whole config text.
pub async fn read(&self) -> Result<String>
pub async fn load_table(&self) -> Result<Table>
Sourcepub async fn backup(&self) -> Result<()>
pub async fn backup(&self) -> Result<()>
Rotates the backups and copies the current file to .bak.
Sourcepub async fn write_checked(&self, content: &str) -> Result<()>
pub async fn write_checked(&self, content: &str) -> Result<()>
Writes a text already checked, owner-only.
Sourcepub async fn save(&self, content: &str) -> Result<()>
pub async fn save(&self, content: &str) -> Result<()>
Checks a text, backs the file up and writes it. A failed backup is logged, not fatal.
Sourcepub async fn save_table(&self, doc: &Table) -> Result<()>
pub async fn save_table(&self, doc: &Table) -> Result<()>
ConfigFile::save for a parsed table.
Trait Implementations§
Source§impl Clone for ConfigFile
impl Clone for ConfigFile
Auto Trait Implementations§
impl !RefUnwindSafe for ConfigFile
impl !UnwindSafe for ConfigFile
impl Forget for ConfigFile
impl Freeze for ConfigFilewhere
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
*const ArcInner<dyn ConfigCheck> is !null: Freeze,
PhantomData<ArcInner<dyn ConfigCheck>>: Freeze,
impl Move for ConfigFile
impl Send for ConfigFile
impl Sync for ConfigFile
impl Unpin for ConfigFile
impl UnsafeUnpin for ConfigFilewhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
*const ArcInner<dyn ConfigCheck> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn ConfigCheck>>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more