1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// =============================================================================
// Copyright (c) 2026 Haixing Hu.
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0.
// =============================================================================
//! Retry policy for recoverable synchronous stream interruptions.
use io;
use ByteInput;
use Input;
use crateFsEffectState;
use crateFsError;
use crateFsErrorKind;
/// Reports whether an interruption is safe to retry without losing effects.
///
/// Filesystem errors are retryable only when their effect state is absent or
/// explicitly unchanged; ordinary interrupted I/O errors are retryable.
///
/// # Parameters
/// - `error`: I/O failure whose retry safety is being classified.
///
/// # Returns
/// `true` only for an ordinary interrupted I/O error or a filesystem
/// interruption known to have no effect.
/// Reads from `input`, retrying interruptions known not to have changed state.
///
/// `before_read` runs before each read attempt, including retries. An ordinary
/// I/O interruption is retried; a filesystem interruption is retried only when
/// its effect state is absent or explicitly unchanged. Other errors, including
/// filesystem interruptions with uncertain or applied effects, are returned
/// immediately.
///
/// # Type Parameters
/// - `I`: Byte-input implementation being read; unsized implementations are
/// accepted behind a reference.
///
/// # Parameters
///
/// * `input` is the byte input to read.
/// * `output` receives bytes read by the input.
/// * `before_read` performs per-attempt setup and can stop the operation by
/// returning an error.
///
/// # Returns
///
/// The number of bytes read, or zero when the input reaches end of stream.
///
/// # Errors
///
/// Returns an error from `before_read`, a non-retryable input error, or a
/// retryable input error after any later setup attempt fails.
pub Sized>