Runtime-sink-file-reopen-truncate
Reopen the file sink behind a RuntimeSink in truncate mode. This helper is the explicit truncate-oriented direct recovery or reset shortcut.
Interface
pub fn RuntimeSink::file_reopen_truncate(self : RuntimeSink) -> Bool {input
self : RuntimeSink- Runtime sink whose file sink should be reopened in truncate mode.
output
Bool- Whether reopen succeeded.
Explanation
Detailed rules explaining key parameters and behaviors
- Plain
Fileruntime variants reopen in truncate mode. QueuedFileruntime variants forward reopen behavior to the wrapped inner file sink.- This helper is a specialized shortcut for a common reset-style reopen mode.
- Non-file runtime variants return
false.
How to Use
Here are some specific examples provided.
When Need A Fresh Output File
When a runtime file should be reopened from an empty state:
ignore(sink.file_reopen_truncate())In this example, reopen behavior truncates the file before future writes continue.
When Want An Explicit Truncate Shortcut
When code should make destructive reopen intent obvious:
let ok = sink.file_reopen_truncate()In this example, the call site expresses reset-style reopen behavior directly.
Error Case
e.g.:
If the runtime sink is not file-backed, the method returns
false.If callers want to preserve existing file content,
file_reopen_append()is the correct API.
Notes
Use this helper when starting from a fresh file is intentional.
Truncate-mode reopen is a stronger action than generic reopen recovery.