2.2 KiB
name, group, category, update-time, description, key-word
| name | group | category | update-time | description | key-word | ||||
|---|---|---|---|---|---|---|---|---|---|
| runtime-sink-file-policy-or-none | api | runtime | 20260707 | Read the current runtime file policy from a RuntimeSink only when it is actually file-backed. |
|
Runtime-sink-file-policy-or-none
Read the current runtime file policy from a RuntimeSink only when it is actually file-backed.
This is the truthful companion to file_policy(). Prefer it for diagnostics and recovery logic that must avoid fallback policy objects.
Interface
pub fn RuntimeSink::file_policy_or_none(self : RuntimeSink) -> FileSinkPolicy? {
input
self : RuntimeSink- Runtime sink whose current file policy should be inspected.
output
FileSinkPolicy?-Some(policy)when the runtime sink is file-backed, otherwiseNone.
Explanation
Detailed rules explaining key parameters and behaviors
- Plain
Fileruntime variants returnSome(current_policy). QueuedFileruntime variants forward the wrapped inner file sink policy asSome(current_policy).- Non-file runtime variants return
None. - This helper is broader than
file_append_mode()orfile_auto_flush()because it returns the whole policy object without fallback synthesis.
How to Use
Here are some specific examples provided.
When Need Truthful Policy Diagnostics
When diagnostics should inspect file policy only if file semantics exist:
match sink.file_policy_or_none() {
Some(policy) => ignore(policy)
None => ()
}
In this example, None means there is no real file policy to inspect.
When Need Compatibility-free Recovery Decisions
When recovery logic should not treat a fallback object as real state:
let maybe_policy = sink.file_policy_or_none()
In this example, callers can distinguish missing file semantics from a live policy snapshot.
Error Case
e.g.:
-
If the runtime sink is not file-backed, the method returns
None. -
If callers need default-policy comparison, pair it with
file_default_policy_or_none().
Notes
-
Prefer this helper over
file_policy()for truthful runtime diagnostics. -
file_policy()remains available as the compatibility fallback API.