silk/writer
Profiles: aarch64-apple-darwin, aarch64-unknown-linux-gnu, aarch64-unknown-linux-gnu-no-libc, wasm32-unknown-unknown, x86_64-unknown-linux-gnu, x86_64-unknown-linux-gnu-no-libc.
Complete stdout and stderr byte writes through a replaceable service.
When to use
Use Writer when code must write complete byte sequences without selecting a destination.
Use silk.os_writer providers at a native process boundary. Use silk.logger.Logger for
structured log events.
Details
A Writer requirement remains in an Effect until a caller supplies a provider. Applications and
tests can replace the provider for one lexical operation. Provider failure produces
WriterError.
Gotchas
Native providers live in silk.os_writer and require selected Darwin or GNU libc. ignoreError removes the typed
failure value and returns unit for a failed Effect.
Import as Writer with import silk.writer { Writer }.
Public declarations: 2.
WriterError
pub struct WriterErrorA typed failure from a Writer provider that did not complete one write or flush operation.
Writer
pub service WriterA replaceable mutable service for complete byte writes and explicit flush operations.
Operation writeAll
effect<'life0> fn writeAll<'life0>(val: &'life0 [u8]) -> () ! WriterError ? &mut WriterWrites one complete immutable byte sequence through the active Writer provider.
Operation flush
effect<'static> fn flush() -> () ! WriterError ? &mut WriterRequests that the active Writer provider commit its buffered output.
Associated function Writer.failure
pub fn failure() -> WriterErrorCreates a failure for a provider that could not complete a write or flush operation.
Associated function Writer.ignoreError
pub effect<'life3> fn ignoreError<A, E, ?R, 'life3>(self: once Effect<'life3; A ! E ? R>) -> () | A ? RRuns one Effect and converts its typed failure to unit while it preserves a successful value.
Details
This function consumes self one time and preserves its provider requirements. It discards the
error value when the Effect fails.
Associated function Writer.writeString
pub effect<'life0> fn writeString<'life0>(val: string<'life0>) -> () ! WriterError ? &mut WriterWrites the UTF-8 bytes of val through the active Writer provider.