qubit_fs/metadata/write_outcome.rs
1/*******************************************************************************
2 *
3 * Copyright (c) 2026 Haixing Hu.
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 *
7 * Licensed under the Apache License, Version 2.0.
8 *
9 ******************************************************************************/
10//! Write operation outcome.
11
12use qubit_metadata::Metadata;
13
14/// Outcome returned when a writer is committed.
15#[derive(Clone, Debug, PartialEq)]
16pub struct WriteOutcome {
17 /// Number of bytes written when known.
18 pub bytes_written: Option<u64>,
19 /// Provider version or HTTP-style ETag when known.
20 pub etag: Option<String>,
21 /// Provider-native diagnostics.
22 pub diagnostics: Metadata,
23}
24
25impl WriteOutcome {
26 /// Creates an empty write outcome.
27 ///
28 /// # Returns
29 /// Write outcome with unknown byte count and no diagnostics.
30 #[inline]
31 #[must_use]
32 pub fn new() -> Self {
33 Self::default()
34 }
35}
36
37impl Default for WriteOutcome {
38 #[inline]
39 fn default() -> Self {
40 Self {
41 bytes_written: None,
42 etag: None,
43 diagnostics: Metadata::new(),
44 }
45 }
46}