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
use bytes_parser::BytesParserError;
use thiserror::Error;
/// Errors variants that can be encountered when parsing of `__consumer_offsets` messages.
#[derive(Error, Debug, Eq, PartialEq)]
pub enum KonsumerOffsetsError {
/// The message contains no key, making parsing of the rest of the message impossible.
///
/// The message key contains information to determine the version of the message, on which
/// the rest of the parsing logic depends.
#[error("Cannot parse message without its key: unable to determine version")]
MessageKeyMissing,
/// An error occurred during parsing.
#[error("Failure while parsing bytes: {0}")]
ByteParsingError(#[source] BytesParserError),
#[cfg(feature = "ts_chrono")]
/// An error occurred when parsing milliseconds to [`chrono::DateTime<Utc>`].
#[error("Failed to parse milliseconds into chrono::DateTime<Utc>: {0}")]
ChronoDateTimeUtcParsingError(i64),
#[cfg(feature = "ts_time")]
/// An error occurred when parsing milliseconds to [`time::OffsetDateTime`].
#[error("Failed to parse milliseconds into time::OffsetDateTime: {0}")]
TimeOffsetDateTimeParsingError(#[from] time::error::ComponentRange),
/// Message key refers to a version format which this crate doesn't currently support.
#[error("Encountered a not (yet) supported message version: {0}")]
UnsupportedMessageVersion(i16),
/// Message payload for an [`crate::offset_commit::OffsetCommit`] refers to a schema format which this crate doesn't currently support.
#[error("Encountered a not (yet) supported schema version for offset commit: {0}")]
UnsupportedOffsetCommitSchema(i16),
/// Message payload for a [`crate::group_metadata::GroupMetadata`] refers to a schema format which this crate doesn't currently support.
#[error("Encountered a not (yet) supported schema version for group metadata: {0}")]
UnsupportedGroupMetadataSchema(i16),
/// Message payload for a [`crate::group_metadata::ConsumerProtocolSubscription`] refers to a version format which this crate doesn't currently support.
#[error("Encountered a not (yet) supported consumer protocol subscription version: {0}")]
UnsupportedConsumerProtocolSubscriptionVersion(i16),
/// Message payload for a [`crate::group_metadata::ConsumerProtocolAssignment`] refers to a version format which this crate doesn't currently support.
#[error("Encountered a not (yet) supported consumer protocol assignment version: {0}")]
UnsupportedConsumerProtocolAssignmentVersion(i16),
/// A value of a given type cannot be parsed for a specific version of another type.
#[error("Unable to parse {0} for version {1} of {2}")]
UnableToParseForVersion(String, i16, String),
}
#[cfg(test)]
mod tests {
use crate::utils::is_thread_safe;
use crate::KonsumerOffsetsError;
#[test]
fn test_types_thread_safety() {
is_thread_safe::<KonsumerOffsetsError>();
}
}