pub struct PropertiesWriter<W: Write> { /* private fields */ }
Expand description

Writes to a properties file.

finish() must be called after writing all data.

Implementations§

source§

impl<W: Write> PropertiesWriter<W>

source

pub fn new(writer: W) -> Self

Writes to the given Write stream.

source

pub fn new_with_encoding(writer: W, encoding: &'static Encoding) -> Self

Writes to the given Write stream in the given encoding. Note that the Java properties specification specifies ISO-8859-1 encoding for properties files; in most cases, new should be called instead.

source

pub fn write_comment(&mut self, comment: &str) -> Result<(), PropertiesError>

Writes a comment to the file.

source

pub fn write(&mut self, key: &str, value: &str) -> Result<(), PropertiesError>

Writes a key/value pair to the file.

source

pub fn flush(&mut self) -> Result<(), PropertiesError>

Flushes the underlying stream.

source

pub fn set_comment_prefix( &mut self, prefix: &str ) -> Result<(), PropertiesError>

Sets the comment prefix.

The prefix must contain a ‘#’ or a ‘!’, may only contain spaces, tabs, or form feeds before the comment character, and may not contain any carriage returns or line feeds (‘\r’ or ‘\n’).

source

pub fn set_kv_separator( &mut self, separator: &str ) -> Result<(), PropertiesError>

Sets the key/value separator.

The separator may be non-empty whitespace, or a colon with optional whitespace on either side, or an equals sign with optional whitespace on either side. (Whitespace here means ’ ’, ‘\t’, or ‘\f’.)

source

pub fn set_line_ending(&mut self, line_ending: LineEnding)

Sets the line ending.

source

pub fn finish(&mut self) -> Result<(), PropertiesError>

Finishes the encoding.

Auto Trait Implementations§

§

impl<W> RefUnwindSafe for PropertiesWriter<W>where W: RefUnwindSafe,

§

impl<W> Send for PropertiesWriter<W>where W: Send,

§

impl<W> Sync for PropertiesWriter<W>where W: Sync,

§

impl<W> Unpin for PropertiesWriter<W>where W: Unpin,

§

impl<W> UnwindSafe for PropertiesWriter<W>where W: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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 Twhere 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 Twhere 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.