community_name: String,
}
-impl ToApub<GroupExt> for Community {
+impl ToApub for Community {
+ type Response = GroupExt;
+
// Turn a Lemmy Community into an ActivityPub group that can be sent out over the network.
fn to_apub(&self, conn: &PgConnection) -> Result<GroupExt, Error> {
let mut group = Group::default();
}
}
-impl FromApub<GroupExt> for CommunityForm {
+impl FromApub for CommunityForm {
+ type ApubType = GroupExt;
+
/// Parse an ActivityPub group received from another instance into a Lemmy community.
fn from_apub(group: &GroupExt, conn: &PgConnection) -> Result<Self, Error> {
let oprops = &group.base.base.object_props;
}
// TODO Not sure good names for these
-pub trait ToApub<Response> {
- fn to_apub(&self, conn: &PgConnection) -> Result<Response, Error>;
+pub trait ToApub {
+ type Response;
+ fn to_apub(&self, conn: &PgConnection) -> Result<Self::Response, Error>;
}
-pub trait FromApub<ApubType> {
- fn from_apub(apub: &ApubType, conn: &PgConnection) -> Result<Self, Error>
+pub trait FromApub {
+ type ApubType;
+ fn from_apub(apub: &Self::ApubType, conn: &PgConnection) -> Result<Self, Error>
where
Self: Sized;
}
Ok(create_apub_response(&post.to_apub(&db.get().unwrap())?))
}
-impl ToApub<Page> for Post {
+impl ToApub for Post {
+ type Response = Page;
+
// Turn a Lemmy post into an ActivityPub page that can be sent out over the network.
fn to_apub(&self, conn: &PgConnection) -> Result<Page, Error> {
let mut page = Page::default();
}
}
-impl FromApub<Page> for PostForm {
+impl FromApub for PostForm {
+ type ApubType = Page;
+
/// Parse an ActivityPub page received from another instance into a Lemmy post.
fn from_apub(page: &Page, conn: &PgConnection) -> Result<PostForm, Error> {
let oprops = &page.object_props;
user_name: String,
}
-impl ToApub<PersonExt> for User_ {
+impl ToApub for User_ {
+ type Response = PersonExt;
+
// Turn a Lemmy Community into an ActivityPub group that can be sent out over the network.
fn to_apub(&self, _conn: &PgConnection) -> Result<PersonExt, Error> {
// TODO go through all these to_string and to_owned()
}
}
-impl FromApub<PersonExt> for UserForm {
+impl FromApub for UserForm {
+ type ApubType = PersonExt;
/// Parse an ActivityPub person received from another instance into a Lemmy user.
fn from_apub(person: &PersonExt, _conn: &PgConnection) -> Result<Self, Error> {
let oprops = &person.base.base.object_props;