1use async_trait::async_trait;
2use serde::{Deserialize, Serialize};
3use strum::{Display, EnumIter};
4
5#[cfg(feature = "avtrdb")]
6pub mod avtrdb;
7#[cfg(feature = "avtrzip")]
8pub mod avtrzip;
9#[cfg(feature = "cutedb")]
10pub mod cutedb;
11#[cfg(feature = "kitsunedb")]
12pub mod kitsunedb;
13#[cfg(feature = "nsvr")]
14pub mod nsvr;
15#[cfg(feature = "paw")]
16pub mod paw;
17#[cfg(feature = "vrcdb")]
18pub mod vrcdb;
19#[cfg(feature = "vrcwb")]
20pub mod vrcwb;
21
22pub mod prelude;
23
24#[repr(u32)]
25#[derive(
26 EnumIter, Display, Deserialize, Serialize, Clone, Copy, PartialEq, Eq, PartialOrd, Hash,
27)]
28pub enum ProviderKind {
29 #[cfg(feature = "avtrdb")]
30 #[strum(to_string = "avtrDB - Avatar Search")]
31 AVTRDB = 1 << 0,
32 #[cfg(feature = "nsvr")]
33 #[strum(to_string = "NSVR - NekoSune Community")]
34 #[serde(alias = "VRCDS")]
35 NSVR = 1 << 1,
36 #[cfg(feature = "paw")]
37 #[strum(to_string = "PAW - Puppy's Avatar World")]
38 PAW = 1 << 2,
39 #[cfg(feature = "vrcdb")]
40 #[strum(to_string = "VRCDB - Avatar Search")]
41 VRCDB = 1 << 3,
42 #[cfg(feature = "vrcwb")]
43 #[strum(to_string = "VRCWB - World Balancer")]
44 VRCWB = 1 << 4,
45 #[cfg(feature = "avtrzip")]
46 #[strum(to_string = "avtr․zip - Advanced Avatar Search")]
47 AVTRZIP = 1 << 5,
48 #[cfg(feature = "kitsunedb")]
49 #[strum(to_string = "KitsuneDB - Avatar Database")]
50 KITSUNEDB = 1 << 6,
51 #[cfg(feature = "cutedb")]
52 #[strum(to_string = "CuteDB - Cutest Avatar Search")]
53 CUTEDB = 1 << 7,
54}
55
56#[async_trait]
57pub trait Provider: Sync + Send {
58 fn kind(&self) -> ProviderKind;
60
61 async fn send_avatar_id(&self, avatar_id: &str) -> anyhow::Result<bool>;
68}
69
70#[macro_export]
72macro_rules! provider {
73 ($x:expr) => {
74 std::sync::Arc::new(Box::new($x) as Box<dyn $crate::provider::Provider>)
75 };
76}