···11[package]
22name = "bluepds"
33version = "0.0.0"
44-edition = "2021"
44+edition = "2024"
55publish = false
66+authors = ["Justin Moore", "Timothy Quilling <teqed@shatteredsky.net>"]
77+description = "Alternative ATProto PDS implementation"
88+license = ""
99+readme = "README.md"
1010+repository = "https://github.com/DrChat/bluepds"
1111+keywords = ["atproto", "pds"]
1212+categories = []
1313+1414+[profile.dev.package."*"]
1515+opt-level = 3
1616+1717+[profile.dev]
1818+opt-level = 1
1919+2020+[profile.release]
2121+opt-level = "s" # Slightly slows compile times, great improvements to file size and runtime performance.
2222+lto = "thin" # Do a second optimization pass over the entire program, including dependencies.
2323+codegen-units = 1 # Compile the entire crate as one unit.
2424+strip = "debuginfo" # Strip all debugging information from the binary to slightly reduce file size.
2525+2626+[lints.rust]
2727+## Groups
2828+# warnings = { level = "warn", priority = -1 } # All lints that are set to issue warnings
2929+# deprecated-safe = { level = "warn", priority = -1 } # Lints for functions which were erroneously marked as safe in the past
3030+# future-incompatible = { level = "warn", priority = -1 } # Lints that detect code that has future-compatibility problems
3131+# keyword-idents = { level = "warn", priority = -1 } # Lints that detect identifiers which will be come keywords in later editions
3232+# let-underscore = { level = "warn", priority = -1 } # Lints that detect wildcard let bindings that are likely to be invalid
3333+# nonstandard-style = { level = "warn", priority = -1 } # Violation of standard naming conventions
3434+# refining-impl-trait = { level = "warn", priority = -1 } # Detects refinement of impl Trait return types by trait implementations
3535+# rust-2018-compatibility = { level = "warn", priority = -1 } # Lints used to transition code from the 2015 edition to 2018
3636+# rust-2021-compatibility = { level = "warn", priority = -1 } # Lints used to transition code from the 2018 edition to 2021
3737+# rust-2018-idioms = { level = "warn", priority = -1 } # Lints to nudge you toward idiomatic features of Rust 2018
3838+# rust-2024-compatibility = { level = "warn", priority = -1 } # Lints used to transition code from the 2021 edition to 2024
3939+# unused = { level = "warn", priority = -1 } # Lints that detect things being declared but not used, or excess syntax
4040+## Individual
4141+ambiguous_negative_literals = "warn" # checks for cases that are confusing between a negative literal and a negation that's not part of the literal.
4242+closure_returning_async_block = "warn" # detects cases where users write a closure that returns an async block. # nightly
4343+ffi_unwind_calls = "warn"
4444+# fuzzy_provenance_casts = "warn" # unstable
4545+# lossy_provenance_casts = "warn" # unstable
4646+macro_use_extern_crate = "warn"
4747+meta_variable_misuse = "warn"
4848+missing_abi = "warn"
4949+missing_copy_implementations = "allow" # detects potentially-forgotten implementations of Copy for public types.
5050+missing_debug_implementations = "allow" # detects missing implementations of fmt::Debug for public types.
5151+missing_docs = "warn"
5252+# multiple_supertrait_upcastable = "warn" # unstable
5353+# must_not_suspend = "warn" # unstable
5454+non_ascii_idents = "warn"
5555+# non_exhaustive_omitted_patterns = "warn" # unstable
5656+redundant_imports = "warn"
5757+redundant_lifetimes = "warn"
5858+rust_2024_incompatible_pat = "warn" # nightly
5959+single_use_lifetimes = "warn"
6060+trivial_casts = "warn"
6161+trivial_numeric_casts = "warn"
6262+unit_bindings = "warn"
6363+unnameable_types = "warn"
6464+# unqualified_local_imports = "warn" # unstable
6565+unreachable_pub = "warn"
6666+unsafe_code = "forbid"
6767+unstable_features = "warn"
6868+# unused_crate_dependencies = "warn"
6969+unused_import_braces = "warn"
7070+unused_lifetimes = "warn"
7171+unused_qualifications = "warn"
7272+unused_results = "warn"
7373+variant_size_differences = "warn"
7474+elided_lifetimes_in_paths = "allow"
7575+# unstable-features = "allow"
7676+7777+[lints.clippy]
7878+# Groups
7979+# nursery = { level = "warn", priority = -1 }
8080+# correctness = { level = "warn", priority = -1 }
8181+# suspicious = { level = "warn", priority = -1 }
8282+# complexity = { level = "warn", priority = -1 }
8383+# perf = { level = "warn", priority = -1 }
8484+# style = { level = "warn", priority = -1 }
8585+8686+# pedantic = { level = "warn", priority = -1 }
8787+# restriction = { level = "warn", priority = -1 }
8888+cargo = { level = "warn", priority = -1 }
8989+# Temporary Allows
9090+single_call_fn = "allow"
9191+multiple_crate_versions = "allow"
9292+expect_used = "allow"
9393+# Style Allows
9494+implicit_return = "allow"
9595+self_named_module_files = "allow"
9696+else_if_without_else = "allow"
9797+std_instead_of_alloc = "allow"
9898+std_instead_of_core = "allow"
9999+blanket_clippy_restriction_lints = "allow"
100100+float_arithmetic = "allow"
101101+redundant_pub_crate = "allow"
102102+pub_with_shorthand = "allow"
103103+absolute_paths = "allow"
104104+module_name_repetitions = "allow"
105105+missing_trait_methods = "allow"
106106+separated_literal_suffix = "allow"
107107+exhaustive_structs = "allow"
108108+field_scoped_visibility_modifiers = "allow"
109109+allow_attributes_without_reason = "allow"
110110+# Warns
111111+missing_docs_in_private_items = "warn"
112112+use_self = "warn"
113113+str_to_string = "warn"
114114+print_stdout = "warn"
115115+unseparated_literal_suffix = "warn"
116116+unwrap_used = "warn"
117117+# Denys
118118+enum_glob_use = "deny"
119119+# expect_used = "deny"
61207121[dependencies]
8122atrium-api = "0.25"
+1
build.rs
···11+//! This file is used to tell cargo to recompile the project if the migrations folder changes.
12fn main() {
23 println!("cargo:rerun-if-changed=migrations");
34}
+4-3
src/auth.rs
···1919}
20202121impl AuthenticatedUser {
2222+ /// Get the DID of the authenticated user.
2223 pub(crate) fn did(&self) -> String {
2324 self.did.clone()
2425 }
···8485 .await
8586 .with_context(|| format!("failed to query account {did}"))?;
86878787- Ok(AuthenticatedUser {
8888- did: did.to_string(),
8888+ Ok(Self {
8989+ did: did.to_owned(),
8990 })
9091 } else {
9192 Err(Error::with_status(
···148149 .context("failed to decode claims")?;
149150 let claims = serde_json::from_slice(&claims).context("failed to parse claims as json")?;
150151151151- Ok((typ.to_string(), claims))
152152+ Ok((typ.to_owned(), claims))
152153}
+4
src/config.rs
···11+//! Configuration structures for the PDS.
12use std::{net::SocketAddr, path::PathBuf};
2334use serde::Deserialize;
45use url::Url;
5677+/// The metrics configuration.
68pub(crate) mod metrics {
79 use super::*;
810911 #[derive(Deserialize, Debug, Clone)]
1212+ /// The Prometheus configuration.
1013 pub(crate) struct PrometheusConfig {
1114 /// The URL of the Prometheus server's exporter endpoint.
1215 pub url: Url,
···1619#[derive(Deserialize, Debug, Clone)]
1720#[serde(tag = "type")]
1821pub(crate) enum MetricConfig {
2222+ /// The Prometheus push gateway.
1923 PrometheusPush(metrics::PrometheusConfig),
2024}
2125
···11+//! PLC operations.
12use std::collections::HashMap;
2334use anyhow::{Context, bail};
···12131314#[derive(Debug, Deserialize, Serialize, Clone)]
1415#[serde(rename_all = "camelCase", tag = "type")]
1616+/// A PLC service.
1517pub(crate) enum PlcService {
1618 #[serde(rename = "AtprotoPersonalDataServer")]
1717- Pds { endpoint: String },
1919+ /// A personal data server.
2020+ Pds {
2121+ /// The URL of the PDS.
2222+ endpoint: String
2323+ },
1824}
19252026#[derive(Debug, Deserialize, Serialize, Clone)]
···3036}
31373238impl PlcOperation {
3939+ /// Sign an operation with the provided signature.
3340 pub(crate) fn sign(self, sig: Vec<u8>) -> SignedPlcOperation {
3441 SignedPlcOperation {
3542 typ: self.typ,
···45524653#[derive(Debug, Deserialize, Serialize, Clone)]
4754#[serde(rename_all = "camelCase")]
5555+/// A signed PLC operation.
4856pub(crate) struct SignedPlcOperation {
4957 #[serde(rename = "type")]
5058 pub typ: String,
···65736674/// Submit a PLC operation to the public directory.
6775pub(crate) async fn submit(client: &Client, did: &str, op: &SignedPlcOperation) -> anyhow::Result<()> {
6868- debug!("submitting {} {}", did, serde_json::to_string(&op).unwrap());
7676+ debug!("submitting {} {}", did, serde_json::to_string(&op).expect("should serialize"));
69777078 let res = client
7179 .post(format!("{PLC_DIRECTORY}{did}"))
···84928593 bail!(
8694 "error from PLC directory: {}",
8787- serde_json::to_string(&e).unwrap()
9595+ serde_json::to_string(&e).expect("should serialize")
8896 );
8997 }
9098}
+4-1
src/storage.rs
···10101111use crate::{Db, config::RepoConfig};
12121313+/// Open a block store for a given DID.
1314pub(crate) async fn open_store(
1415 config: &RepoConfig,
1516 did: impl Into<String>,
···3132 CarStore::open(f).await.context("failed to open car store")
3233}
33343535+/// Open a repository for a given DID.
3436pub(crate) async fn open_repo_db(
3537 config: &RepoConfig,
3638 db: &Db,
···4850 .await
4951 .context("failed to query database")?;
50525151- open_repo(config, did, Cid::from_str(&cid).unwrap()).await
5353+ open_repo(config, did, Cid::from_str(&cid).expect("should be valid CID")).await
5254}
53555656+/// Open a repository for a given DID and CID.
5457pub(crate) async fn open_repo(
5558 config: &RepoConfig,
5659 did: impl Into<String>,