Consolidate base traits and types into Core

This commit is contained in:
Aode (lion) 2021-11-18 09:25:53 -06:00
parent cea3fc807e
commit 9ba1383596
33 changed files with 49 additions and 101 deletions

View file

@ -11,16 +11,11 @@ edition = "2021"
members = [
"apub-awc",
"apub-breaker-session",
"apub-deliver",
"apub-deref",
"apub-core",
"apub-deref-client",
"apub-digest",
"apub-objectid",
"apub-openssl",
"apub-reqwest",
"apub-rustcrypto",
"apub-session",
"apub-signer",
"examples/awc-example",
"examples/example-types",
"examples/reqwest-example"

View file

@ -7,11 +7,7 @@ edition = "2021"
[dependencies]
actix-http = { version = "3.0.0-beta.12", default-features = false }
apub-deliver = { version = "0.1.0", path = "../apub-deliver/" }
apub-digest = { version = "0.1.0", path = "../apub-digest/" }
apub-deref = { version = "0.1.0", path = "../apub-deref/" }
apub-session = { version = "0.1.0", path = "../apub-session/" }
apub-signer = { version = "0.1.0", path = "../apub-signer/" }
apub-core = { version = "0.1.0", path = "../apub-core/" }
awc = { version = "3.0.0-beta.10", default-features = false }
http-signature-normalization-actix = { version = "0.5.0-beta.12", default-features = false, features = ["client", "digest"] }
serde = "1"

View file

@ -1,8 +1,10 @@
use actix_http::error::BlockingError;
use apub_deref::{Dereference, Repo};
use apub_digest::{Digest, DigestFactory};
use apub_session::Session;
use apub_signer::{Sign, SignFactory};
use apub_core::{
deref::{Dereference, Repo},
digest::{Digest, DigestFactory},
session::Session,
signature::{Sign, SignFactory},
};
use awc::{http::header::HttpDate, Client};
use http_signature_normalization_actix::{
digest::DigestName,
@ -189,7 +191,7 @@ where
}
}
impl<'a, CurrentSession, Crypto> apub_deliver::Client<'a> for AwcClient<'a, CurrentSession, Crypto>
impl<'a, CurrentSession, Crypto> apub_core::deliver::Client<'a> for AwcClient<'a, CurrentSession, Crypto>
where
CurrentSession: Session,
Crypto: DigestFactory + SignFactory + 'static,

View file

@ -6,6 +6,6 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
apub-session = { version = "0.1.0", path = "../apub-session/" }
apub-core = { version = "0.1.0", path = "../apub-core/" }
dashmap = "4.0.2"
url = "2"

View file

@ -1,4 +1,4 @@
use apub_session::Session;
use apub_core::session::Session;
use dashmap::DashMap;
use std::{
sync::Arc,

View file

@ -1,5 +1,5 @@
[package]
name = "apub-deref"
name = "apub-core"
version = "0.1.0"
edition = "2021"

6
apub-core/src/lib.rs Normal file
View file

@ -0,0 +1,6 @@
pub mod deliver;
pub mod deref;
pub mod digest;
pub mod object_id;
pub mod session;
pub mod signature;

View file

@ -1,10 +0,0 @@
[package]
name = "apub-deliver"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
serde = "1"
url = "2"

View file

@ -6,7 +6,7 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
apub-deref = { version = "0.1.0", path = "../apub-deref/" }
apub-core = { version = "0.1.0", path = "../apub-core/" }
pin-project-lite = "0.2.7"
thiserror = "1"
url = "2"

View file

@ -1,4 +1,4 @@
use apub_deref::{Dereference, Repo};
use apub_core::deref::{Dereference, Repo};
use std::{
future::Future,
pin::Pin,

View file

@ -1,2 +0,0 @@
/target
Cargo.lock

View file

@ -1,8 +0,0 @@
[package]
name = "apub-digest"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

View file

@ -1,10 +0,0 @@
[package]
name = "apub-objectid"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
serde = "1"
url = { version = "2", features = ["serde"] }

View file

@ -6,6 +6,5 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
apub-digest = { version = "0.1.0", path = "../apub-digest/" }
apub-signer = { version = "0.1.0", path = "../apub-signer/" }
apub-core = { version = "0.1.0", path = "../apub-core/" }
openssl = "0.10.36"

View file

@ -30,7 +30,7 @@ impl OpenSsl {
}
}
impl<'a> apub_digest::Digest for OpenSslDigest {
impl<'a> apub_core::digest::Digest for OpenSslDigest {
const NAME: &'static str = "SHA-256";
fn digest(mut self, input: &[u8]) -> String {
@ -41,7 +41,7 @@ impl<'a> apub_digest::Digest for OpenSslDigest {
}
}
impl apub_signer::Sign for OpenSslSigner {
impl apub_core::signature::Sign for OpenSslSigner {
type Error = ErrorStack;
fn sign(&self, signing_string: &str) -> Result<String, Self::Error> {
@ -52,7 +52,7 @@ impl apub_signer::Sign for OpenSslSigner {
}
}
impl apub_digest::DigestFactory for OpenSsl {
impl apub_core::digest::DigestFactory for OpenSsl {
type Digest = OpenSslDigest;
fn digest(&self) -> Self::Digest {
@ -62,7 +62,7 @@ impl apub_digest::DigestFactory for OpenSsl {
}
}
impl apub_signer::SignFactory for OpenSsl {
impl apub_core::signature::SignFactory for OpenSsl {
type Signer = OpenSslSigner;
type KeyId = String;

View file

@ -6,11 +6,7 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
apub-deliver = { version = "0.1.0", path = "../apub-deliver/" }
apub-deref = { version = "0.1.0", path = "../apub-deref/" }
apub-digest = { version = "0.1.0", path = "../apub-digest/" }
apub-session = { version = "0.1.0", path = "../apub-session/" }
apub-signer = { version = "0.1.0", path = "../apub-signer/" }
apub-core = { version = "0.1.0", path = "../apub-core/" }
http-signature-normalization-reqwest = { version = "0.2.0", default-features = false, features = ["digest"] }
httpdate = "1.0.2"
reqwest = { version = "0.11.6", default-features = false, features = ["json"] }

View file

@ -1,7 +1,9 @@
use apub_deref::{Dereference, Repo};
use apub_digest::{Digest, DigestFactory};
use apub_session::Session;
use apub_signer::{Sign, SignFactory};
use apub_core::{
deref::{Dereference, Repo},
digest::{Digest, DigestFactory},
session::Session,
signature::{Sign, SignFactory},
};
use http_signature_normalization_reqwest::{
digest::{DigestCreate, SignExt},
prelude::{Config, Sign as _, SignError},
@ -182,7 +184,7 @@ where
}
}
impl<'a, CurrentSession, Crypto> apub_deliver::Client<'a>
impl<'a, CurrentSession, Crypto> apub_core::deliver::Client<'a>
for ReqwestClient<'a, CurrentSession, Crypto>
where
CurrentSession: Session + Send + Sync,

View file

@ -6,8 +6,7 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
apub-core = { version = "0.1.0", path = "../apub-core/" }
base64 = "0.13.0"
rsa = "0.5.0"
sha2 = "0.9.0"
apub-digest = { version = "0.1.0", path = "../apub-digest/" }
apub-signer = { version = "0.1.0", path = "../apub-signer" }

View file

@ -25,7 +25,7 @@ impl Rustcrypto {
}
}
impl apub_digest::Digest for Sha256Digest {
impl apub_core::digest::Digest for Sha256Digest {
const NAME: &'static str = "SHA-256";
fn digest(mut self, input: &[u8]) -> String {
@ -36,7 +36,7 @@ impl apub_digest::Digest for Sha256Digest {
}
}
impl apub_signer::Sign for RsaSigner {
impl apub_core::signature::Sign for RsaSigner {
type Error = rsa::errors::Error;
fn sign(&self, signing_string: &str) -> Result<String, Self::Error> {
@ -51,7 +51,7 @@ impl apub_signer::Sign for RsaSigner {
}
}
impl apub_digest::DigestFactory for Rustcrypto {
impl apub_core::digest::DigestFactory for Rustcrypto {
type Digest = Sha256Digest;
fn digest(&self) -> Self::Digest {
@ -61,7 +61,7 @@ impl apub_digest::DigestFactory for Rustcrypto {
}
}
impl apub_signer::SignFactory for Rustcrypto {
impl apub_core::signature::SignFactory for Rustcrypto {
type Signer = RsaSigner;
type KeyId = String;

View file

@ -1,9 +0,0 @@
[package]
name = "apub-session"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
url = "2"

View file

@ -1,8 +0,0 @@
[package]
name = "apub-signer"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

View file

@ -9,7 +9,7 @@ edition = "2021"
actix-rt = "2.4.0"
apub-awc = { version = "0.1.0", path = "../../apub-awc/" }
apub-breaker-session = { version = "0.1.0", path = "../../apub-breaker-session/" }
apub-session = { version = "0.1.0", path = "../../apub-session/" }
apub-core = { version = "0.1.0", path = "../../apub-core/" }
apub-rustcrypto = { version = "0.1.0", path = "../../apub-rustcrypto/" }
awc = { version = "3.0.0-beta.10", default-features = false, features = ["rustls"] }
example-types = { version = "0.1.0", path = "../example-types/" }

View file

@ -1,7 +1,7 @@
use apub_awc::AwcClient;
use apub_breaker_session::BreakerSession;
use apub_rustcrypto::Rustcrypto;
use apub_session::RequestCountSession;
use apub_core::session::RequestCountSession;
use example_types::{object_id, NoteType, ObjectId};
use http_signature_normalization_actix::Config;
use rsa::RsaPrivateKey;

View file

@ -6,8 +6,6 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
apub-deliver = { version = "0.1.0", path = "../../apub-deliver/" }
apub-deref = { version = "0.1.0", path = "../../apub-deref/" }
apub-objectid = { version = "0.1.0", path = "../../apub-objectid/" }
apub-core = { version = "0.1.0", path = "../../apub-core/" }
serde = { version = "1", features = ["derive"] }
url = { version = "2", features = ["serde"] }

View file

@ -1,5 +1,7 @@
use apub_deliver::Client;
use apub_deref::{Dereference, Repo};
use apub_core::{
deliver::Client,
deref::{Dereference, Repo},
};
use std::{
fmt::Display,
ops::{Deref, DerefMut},
@ -8,13 +10,13 @@ use url::Url;
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
#[serde(transparent)]
pub struct ObjectId<Kind>(apub_objectid::ObjectId<Kind>);
pub struct ObjectId<Kind>(apub_core::object_id::ObjectId<Kind>);
pub fn object_id<Kind>(id: Url) -> ObjectId<Kind>
where
ObjectId<Kind>: Dereference,
{
ObjectId(apub_objectid::ObjectId::new(id))
ObjectId(apub_core::object_id::ObjectId::new(id))
}
#[derive(Debug, serde::Deserialize, serde::Serialize)]

View file

@ -7,7 +7,7 @@ edition = "2021"
[dependencies]
apub-breaker-session = { version = "0.1.0", path = "../../apub-breaker-session/" }
apub-session = { version = "0.1.0", path = "../../apub-session/" }
apub-core = { version = "0.1.0", path = "../../apub-core/" }
apub-reqwest = { version = "0.1.0", path = "../../apub-reqwest/" }
apub-openssl = { version = "0.1.0", path = "../../apub-openssl/" }
example-types = { version = "0.1.0", path = "../example-types/" }

View file

@ -1,7 +1,7 @@
use apub_breaker_session::BreakerSession;
use apub_core::session::RequestCountSession;
use apub_openssl::OpenSsl;
use apub_reqwest::ReqwestClient;
use apub_session::RequestCountSession;
use example_types::{object_id, NoteType, ObjectId};
use http_signature_normalization_reqwest::Config;
use openssl::{pkey::PKey, rsa::Rsa};