pub struct TomlEditor<T: Serialize + DeserializeOwned> { /* private fields */ }
Expand description

Wrapper type to Edit something using TOML

Implements Editable itself so it can be used explicitly like con.edit(TomlEditor::new(thing)) or, more conveniently, Editable can be implemented for a particular type to wrap the type automatically when writing con.edit(thing). To this end, the macro edit_as_toml is provided.

Since this uses serde, it requires the type to be Serialize and DeserializeOwned. The trait bound is specifically DeserializeOwned instead of Deserialize because it has to outlive the content of the temporary file and cannot borrow from it.

Implementations§

source§

impl<T: Serialize + DeserializeOwned> TomlEditor<T>

source

pub fn new(thing: T) -> Self

Wrap something to be edited

Trait Implementations§

source§

impl<T: Serialize + DeserializeOwned> Edit for TomlEditor<T>

source§

const EXTENSION: &'static str = "toml"

Extension of the temporary file Read more
§

type T = T

Type returned from editing Read more
§

type Err = EditError<Error>

source§

fn write<W: Write>(&self, w: &mut W) -> Result<(), Self::Err>

Write content into the file to be edited Read more
source§

fn read<C>(&self, content: String, con: &C) -> Option<Self::T>
where C: Conciliator + ?Sized,

Read (and parse) the edited file, immediately reporting any errors encountered Read more

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for TomlEditor<T>
where T: RefUnwindSafe,

§

impl<T> Send for TomlEditor<T>
where T: Send,

§

impl<T> Sync for TomlEditor<T>
where T: Sync,

§

impl<T> Unpin for TomlEditor<T>
where T: Unpin,

§

impl<T> UnwindSafe for TomlEditor<T>
where T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> Editable for T
where T: Edit,

§

type E = T

Edit type this converts to
source§

fn into_edit(self) -> T

Perform the conversion
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.