2.3 KiB
name, group, category, update-time, description, key-word
| name | group | category | update-time | description | key-word | ||||
|---|---|---|---|---|---|---|---|---|---|
| file-sink-type | api | sink | 20260707 | Public file sink type re-exported from file_runtime for file-backed synchronous logging. |
|
File-sink-type
FileSink is the public file sink type used for file-backed synchronous logging. On the root src facade, it is re-exported from src/file_runtime, which is the real owner of the concrete sink behavior type.
Interface
pub using @file_runtime { type FileSink }
output
FileSink- Public native file sink type with runtime policy, state, and failure tracking.
Explanation
Detailed rules explaining key parameters and behaviors
- This root surface is a re-export of the concrete
@file_runtime.FileSinktype. - The struct intentionally hides its fields; callers interact through methods such as
flush(),close(),reopen(),policy(), andstate(). - File model companions such as
FileRotation,FileSinkPolicy,FileSinkState, andRuntimeFileStateare owned by@file_model, not byFileSinkitself. file_sink(...)constructs this type directly from path and policy inputs.- The type exposes runtime helpers such as
flush(),close(),reopen(),policy(),state(), and failure-counter accessors.
How to Use
Here are some specific examples provided.
When Need A Typed Native File Sink Value
When code should keep the concrete file sink type visible:
let sink : FileSink = file_sink("app.log")
In this example, the sink value stays explicit and keeps the file-backed runtime controls available.
When Need A Typed File-backed Logger
When logging should preserve the native file sink type in the logger:
let logger : Logger[FileSink] = Logger::new(file_sink("app.log"), target="file")
In this example, the concrete file sink remains part of the logger type.
Error Case
e.g.:
-
FileSinkitself does not have a runtime failure mode. -
Actual file availability, writes, flushes, and reopen behavior still depend on backend support and filesystem state.
Notes
-
Use
file_sink(...)when you need a value of this type. -
Use
FileSinkState,FileSinkPolicy, andRuntimeFileStatewhen you need exported snapshots or higher-level diagnostics rather than the live sink type itself.