Skip to content

Commit

Permalink
feat: Allow AtpAgent to be excluded as a default feature (#79)
Browse files Browse the repository at this point in the history
* Update xprc, use tokio::sync::RwLock for agent

* Update docs, features
  • Loading branch information
sugyan authored Nov 13, 2023
1 parent 3218eb0 commit 2ce91e0
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 17 deletions.
10 changes: 9 additions & 1 deletion atrium-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,18 @@ cid = { version = "0.10.1", features = ["serde-codec"] }
http = "0.2.9"
serde = { version = "1.0.160", features = ["derive"] }
serde_bytes = "0.11.9"
tokio = { version = "1.33.0", features = ["sync"] }
tokio = { version = "1.33.0", default-features = false, optional = true }

[features]
default = ["agent"]
agent = ["tokio/sync"]

[dev-dependencies]
atrium-xrpc-client = "0.1"
futures = "0.3.28"
serde_json = "1.0.107"
tokio = { version = "1.33.0", features = ["test-util", "macros"] }

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
1 change: 1 addition & 0 deletions atrium-api/src/did_doc.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//! Definitions for DID document types.
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct DidDocument {
Expand Down
6 changes: 4 additions & 2 deletions atrium-api/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// This file is generated by atrium-codegen. DO NOT EDIT.
# ! [doc = include_str ! ("../README.md")]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![doc = include_str!("../README.md")]
pub use atrium_xrpc as xrpc;
#[cfg_attr(docsrs, doc(cfg(feature = "agent")))]
#[cfg(feature = "agent")]
pub mod agent;
pub mod app;
pub mod blob;
Expand Down
13 changes: 5 additions & 8 deletions atrium-codegen/src/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,17 +127,14 @@ pub(crate) fn generate_client(
}

pub(crate) fn generate_modules(outdir: &Path) -> Result<Vec<PathBuf>, Box<dyn Error>> {
let paths = find_dirs(outdir)?;
let mut paths = find_dirs(outdir)?;
paths.retain(|p| p.as_ref() != outdir);
let mut files = Vec::with_capacity(paths.len());
// generate ".rs" files names
for path in &paths {
if path.as_ref() == outdir {
files.push(outdir.join("lib.rs"));
} else {
let mut p = path.as_ref().to_path_buf();
p.set_extension("rs");
files.push(p);
}
let mut p = path.as_ref().to_path_buf();
p.set_extension("rs");
files.push(p);
}
// write "mod" statements
for (path, filepath) in paths.iter().zip(&files) {
Expand Down
10 changes: 4 additions & 6 deletions atrium-codegen/src/token_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,12 +445,10 @@ pub fn refs_enum(refs: &[String], name: &str, schema_id: Option<&str>) -> Result
pub fn modules(names: &[String]) -> Result<TokenStream> {
let v = names
.iter()
.filter_map(|s| {
if s != "lib" {
let m = format_ident!("{s}");
Some(quote!(pub mod #m;))
} else {
None
.map(|s| {
let m = format_ident!("{s}");
quote! {
pub mod #m;
}
})
.collect_vec();
Expand Down

0 comments on commit 2ce91e0

Please sign in to comment.