java_properties

Struct PropertiesWriter

Source
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> Freeze for PropertiesWriter<W>
where W: Freeze,

§

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 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> 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>,

Source§

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>,

Source§

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.