#[non_exhaustive]pub enum WriteError {
UnexpectedRewind {
offset: u64,
persisted: u64,
},
TooMuchProgress {
sent: u64,
persisted: u64,
},
ChecksumMismatch {
mismatch: ChecksumMismatch,
object: Box<Object>,
},
}Expand description
An unrecoverable problem in the upload protocol.
§Example
use std::error::Error as _;
let writer = client
.write_object("projects/_/buckets/my-bucket", "my-object", "hello world")
.set_if_generation_not_match(0);
match writer.send_buffered().await {
Ok(object) => println!("Successfully created the object {object:?}"),
Err(error) if error.is_serialization() => {
println!("Some problem {error:?} sending the data to the service");
if let Some(m) = error.source().and_then(|e| e.downcast_ref::<WriteError>()) {
println!("{m}");
}
},
Err(e) => return Err(e.into()), // not handled in this example
}Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
UnexpectedRewind
The service has “uncommitted” previously persisted bytes.
§Troubleshoot
In the resumable upload protocol the service reports how many bytes are persisted. This error indicates that the service previously reported more bytes as persisted than in the latest report. This could indicate:
- a corrupted message from the service, either the earlier message reporting more bytes persisted than actually are, or the current message indicating fewer bytes persisted.
- a bug in the service, where it reported bytes as persisted when they were not.
- a bug in the client, maybe storing the incorrect byte count, or parsing the messages incorrectly.
All of these conditions indicate a bug, and in Rust it is idiomatic to
panic!() when a bug is detected. However, in this case it seems more
appropriate to report the problem, as the client library cannot
determine the location of the bug.
TooMuchProgress
The service reports more bytes persisted than sent.
§Troubleshoot
Most likely this indicates that two concurrent uploads are using the same session. Review your application design to avoid concurrent uploads.
It is possible that this indicates a bug in the service, client, or messages corrupted in transit.
ChecksumMismatch
The checksums reported by the service do not match the expected checksums.
§Troubleshoot
The client library compares the CRC32C checksum and/or MD5 hash of the uploaded data against the hash reported by the service at the end of the upload. This error indicates the hashes did not match.
If you provided known values for these checksums verify those values are correct.
Otherwise, this is probably a data corruption problem. These are notoriously difficult to root cause. They probably indicate faulty equipment, such as the physical machine hosting your client, the network elements between your client and the service, or the physical machine hosting the service.
If possible, resend the data from a different machine.
Trait Implementations§
Source§impl Debug for WriteError
impl Debug for WriteError
Source§impl Display for WriteError
impl Display for WriteError
Source§impl Error for WriteError
impl Error for WriteError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
Auto Trait Implementations§
impl !Freeze for WriteError
impl RefUnwindSafe for WriteError
impl Send for WriteError
impl Sync for WriteError
impl Unpin for WriteError
impl UnwindSafe for WriteError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.