blob_writer/errors.rs
1// Copyright 2023 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5use thiserror::Error;
6use zx::Status;
7
8/// The error type used by the `BlobWriter` for the create() command.
9#[derive(Clone, Debug, Error)]
10pub enum CreateError {
11 /// A FIDL error occurred.
12 #[error(transparent)]
13 Fidl(#[from] fidl::Error),
14 /// There was a problem getting the shared vmo for the blob.
15 #[error("failed to get vmo")]
16 GetVmo(#[from] Status),
17 /// An error occurred while getting the size of the vmo.
18 #[error("failed to get size of vmo")]
19 GetSize(#[source] Status),
20}
21
22/// The error type used by the `BlobWriter` for the write() command.
23#[derive(Clone, Debug, Error)]
24pub enum WriteError {
25 /// A FIDL error occurred.
26 #[error(transparent)]
27 Fidl(#[from] fidl::Error),
28 /// There was a problem getting the size of the vmo.
29 #[error("failed to get the size of the vmo")]
30 GetSize(#[source] Status),
31 /// The outstanding writes queue ended prematurely.
32 #[error("outstanding writes queue ended prematurely")]
33 QueueEnded,
34 /// An error occurred while making a BytesReady request to the BlobWriter server.
35 #[error("failed to complete a BytesReady request")]
36 BytesReady(#[source] Status),
37 /// An error occurred while writing to the vmo.
38 #[error("failed to write to the vmo")]
39 VmoWrite(#[source] Status),
40 /// Client tried to write past the expected end of the blob.
41 #[error("client tried to write past the expected end of the blob")]
42 EndOfBlob,
43}