Skip to main content

mysql_replication/
error.rs

1use std::io;
2
3#[derive(Debug, thiserror::Error)]
4pub enum Error {
5    #[error("truncated input: need {need} bytes, have {have}")]
6    Truncated { need: usize, have: usize },
7    #[error("invalid binlog: {0}")]
8    Invalid(String),
9    #[error("unsupported: {0}")]
10    Unsupported(String),
11    #[error("CRC32 checksum mismatch")]
12    Checksum,
13    #[error(transparent)]
14    Io(#[from] io::Error),
15    #[error(transparent)]
16    Mysql(#[from] mysql::Error),
17    #[error(transparent)]
18    Utf8(#[from] std::str::Utf8Error),
19}
20pub type Result<T> = std::result::Result<T, Error>;
21pub(crate) fn invalid(message: impl Into<String>) -> Error {
22    Error::Invalid(message.into())
23}