deviantart/
lib.rs

1/// The client
2mod client;
3/// API types
4pub mod types;
5
6pub use self::client::Client;
7pub use self::types::Deviation;
8pub use self::types::DeviationExtended;
9pub use self::types::GetFullviewUrlError;
10pub use self::types::GetFullviewUrlOptions;
11pub use self::types::ListFolderContentsResponse;
12pub use self::types::OEmbed;
13pub use self::types::ScrapedStashInfo;
14pub use self::types::ScrapedWebPageInfo;
15pub use url::Url;
16
17/// Library Error
18#[derive(Debug, thiserror::Error)]
19pub enum Error {
20    /// Reqwest HTTP Error
21    #[error(transparent)]
22    Reqwest(#[from] reqwest::Error),
23
24    /// Invalid Url
25    #[error(transparent)]
26    Url(#[from] url::ParseError),
27
28    /// A tokio task failed to join
29    #[error(transparent)]
30    TokioJoin(#[from] tokio::task::JoinError),
31
32    /// Json failed to parse
33    #[error(transparent)]
34    Json(#[from] serde_json::Error),
35
36    /// A scraped web page was invalid
37    #[error("invalid scraped webpage")]
38    InvalidScrapedWebPage(#[from] self::types::scraped_webpage_info::FromHtmlStrError),
39
40    /// Scraped Stash info was invalid
41    #[error("invalid scraped stash info")]
42    InvalidScrapedStashInfo(#[from] self::types::scraped_stash_info::FromHtmlStrError),
43
44    /// Signing in failed for an unspecified reason
45    #[error("sign in failed")]
46    SignInFailed,
47
48    /// Missing a field
49    #[error("missing field \"{name}\"")]
50    MissingField {
51        /// The missing field name
52        name: &'static str,
53    },
54
55    /// Missing the streams field
56    #[error("missing streams")]
57    MissingStreams,
58
59    /// Missing the browse page stream
60    #[error("missing browse page stream")]
61    MissingBrowsePageStream,
62
63    /// Missing the Deviation of the given id
64    #[error("missing deviation {0}")]
65    MissingDeviation(u64),
66
67    /// A cookie store error occured
68    #[error("cookie store error")]
69    CookieStore(WrapBoxError),
70}
71
72/// A wrapper over a `Box<dyn std::error::Error + Send + Sync + 'static>`.
73#[derive(Debug)]
74pub struct WrapBoxError(pub Box<dyn std::error::Error + Send + Sync + 'static>);
75
76impl std::fmt::Display for WrapBoxError {
77    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
78        self.0.fmt(f)
79    }
80}
81
82impl std::error::Error for WrapBoxError {}
83
84// TODO:
85// investigate deviantart.com/view/<id>
86// ex: deviantart.com/view/852625718