Skip to main content

write

Function write 

Source
pub fn write<T: Display>(path: &Utf8Path, value: T) -> Result<(), WriteError>
Expand description

Writes a value such as a SocketAddr to the path.

ยงNotes

The path must not already exist. A write to an existing file will fail with a WriteStage::Persist error.

The value is written atomically via a temporary file and a rename. This means that readers will not ever see torn or partial writes.

write is generic over Display, so callers can publish any value with a FromStr counterpart on the reader, assuming Display and FromStr roundtrip. In most cases, you will pass in a SocketAddr here.

A single trailing newline is written after the value. The read side of this crate expects (and will strip) exactly one trailing newline.