1
0
Fork 0
forked from alemi/upub

feat(apb): optional Send marker on Base, on by default

This commit is contained in:
əlemi 2024-05-20 02:39:23 +02:00
parent 9d59c73c59
commit f4db94db27
Signed by: alemi
GPG key ID: A4895B84D311642C
3 changed files with 16 additions and 3 deletions

View file

@ -24,13 +24,14 @@ sea-orm = { version = "0.12", optional = true }
reqwest = { version = "0.12", features = ["json"], optional = true }
[features]
default = ["activitypub-miscellaneous-terms"]
default = ["activitypub-miscellaneous-terms", "send"]
# extensions
activitypub-miscellaneous-terms = [] # https://swicg.github.io/miscellany/
activitypub-counters = [] # https://ns.alemi.dev/as/counters/#
activitypub-fe = [] # https://ns.alemi.dev/as/fe/#
litepub = [] # incomplete, https://litepub.social/
# builtin utils
send = []
orm = ["dep:sea-orm"]
fetch = ["dep:reqwest"]
# providers

View file

@ -1,3 +1,15 @@
#[cfg(feature = "send")]
pub trait MaybeSend : Send {}
#[cfg(feature = "send")]
impl<T : Send> MaybeSend for T {}
#[cfg(not(feature = "send"))]
pub trait MaybeSend {}
#[cfg(not(feature = "send"))]
impl<T> MaybeSend for T {}
#[derive(Debug, thiserror::Error)]
#[error("invalid type value")]
pub struct TypeValueError;

View file

@ -8,13 +8,13 @@ crate::strenum! {
};
}
pub trait Base {
pub trait Base : crate::macros::MaybeSend {
fn id(&self) -> Option<&str> { None }
fn base_type(&self) -> Option<BaseType> { None }
}
pub trait BaseMut {
pub trait BaseMut : crate::macros::MaybeSend {
fn set_id(self, val: Option<&str>) -> Self;
fn set_base_type(self, val: Option<BaseType>) -> Self;
}