2023-02-19 12:26:01 +00:00
|
|
|
//#![deny(missing_docs)]
|
2022-06-02 11:17:12 +00:00
|
|
|
|
2023-02-19 12:26:01 +00:00
|
|
|
pub use activitystreams_kinds as kinds;
|
|
|
|
pub mod config;
|
2022-06-02 11:17:12 +00:00
|
|
|
pub mod core;
|
2023-02-19 12:26:01 +00:00
|
|
|
pub mod protocol;
|
2023-02-11 12:32:35 +00:00
|
|
|
pub mod request_data;
|
2022-06-02 11:17:12 +00:00
|
|
|
pub mod traits;
|
|
|
|
pub mod utils;
|
|
|
|
|
|
|
|
/// Mime type for Activitypub, used for `Accept` and `Content-Type` HTTP headers
|
|
|
|
pub static APUB_JSON_CONTENT_TYPE: &str = "application/activity+json";
|
|
|
|
|
2023-02-19 12:26:01 +00:00
|
|
|
/// Error messages returned by this library.
|
2022-06-02 11:17:12 +00:00
|
|
|
#[derive(thiserror::Error, Debug)]
|
|
|
|
pub enum Error {
|
2023-02-19 12:26:01 +00:00
|
|
|
#[error("Object was not found in local database")]
|
2022-06-02 11:17:12 +00:00
|
|
|
NotFound,
|
|
|
|
#[error("Request limit was reached during fetch")]
|
|
|
|
RequestLimit,
|
2023-01-28 03:45:11 +00:00
|
|
|
#[error("Response body limit was reached during fetch")]
|
|
|
|
ResponseBodyLimit,
|
2022-06-02 11:17:12 +00:00
|
|
|
#[error("Object to be fetched was deleted")]
|
|
|
|
ObjectDeleted,
|
|
|
|
#[error("{0}")]
|
|
|
|
UrlVerificationError(&'static str),
|
2023-02-19 12:26:01 +00:00
|
|
|
#[error("Incoming activity has invalid digest for body")]
|
|
|
|
ActivityBodyDigestInvalid,
|
|
|
|
#[error("incoming activity has invalid signature")]
|
|
|
|
ActivitySignatureInvalid,
|
2022-06-02 11:17:12 +00:00
|
|
|
#[error(transparent)]
|
|
|
|
Other(#[from] anyhow::Error),
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Error {
|
|
|
|
pub fn conv<T>(error: T) -> Self
|
|
|
|
where
|
|
|
|
T: Into<anyhow::Error>,
|
|
|
|
{
|
|
|
|
Error::Other(error.into())
|
|
|
|
}
|
|
|
|
}
|
2023-02-19 12:26:01 +00:00
|
|
|
|
|
|
|
impl PartialEq for Error {
|
|
|
|
fn eq(&self, other: &Self) -> bool {
|
|
|
|
std::mem::discriminant(self) == std::mem::discriminant(other)
|
|
|
|
}
|
|
|
|
}
|