Rust libraries for Bluesky's AT Protocol services. NOT STABLE (yet)

Overview

ATrium

ATrium is a collection of Rust libraries designed to work with the AT Protocol, providing a versatile and coherent ecosystem for developers. The name is inspired by the concept of an "atrium" with a view of the open bluesky, reflecting the open nature of the project.

Our goal is to provide a comprehensive, easy-to-use, and efficient library that caters to various use cases and scenarios involving the AT Protocol.

Please note that ATrium is still under active development and many features may be subject to change or enhancement. We appreciate your understanding and patience during this phase.

Overview

ATrium is divided into several sub-projects to address different aspects of the AT Protocol and provide a modular design:

atrium-api

A library consisting of models and messaging definitions for XRPC, primarily generated using the codegen library.

atrium-lex

A library that provides type definitions for parsing the AT Protocol's Lexicon schema, ensuring compatibility with the lexicon.

atrium-codegen

A library that generates Rust code for the atrium-api based on the analyzed lexicon definitions.

atrium-xrpc

A client library that offers a convenient way to interact with the atrium-api and utilize its features.

atrium-cli

A command-line app using this API library.

lexgen command

cargo run --bin lexgen -- --lexdir $HOME/.ghq/github.com/bluesky-social/atproto/lexicons

Contribution

We welcome contributions from the community to help us improve and expand ATrium. If you're interested in contributing, please feel free to submit issues or pull requests on the GitHub repository. We appreciate your support!

License

ATrium is released under the MIT License.

Related works

Below are some related projects that might be of interest:

Comments
  • Subscribe repos example?

    Subscribe repos example?

    Regarding atrium-api/src/com/atproto/sync/subscribe_repos.rs

    It would be great to see some sort of example on how to use this. From brief reading of the code, it seems to not be implemented yet, as I cannot find anything regarding reading streams, events or anything like that. Is that correct?

    enhancement 
    opened by Captain-Of-Coit 6
  • Suggestion: Change code writer

    Suggestion: Change code writer

    Hey, you folks could use a set of crates to assemble the generated code in a more structured manner:

    • Use https://crates.io/crates/quote to write the individual pieces of code
    • Use https://crates.io/crates/syn and https://crates.io/crates/proc-macro2 to have structs for pieces of Idents for the struct names etc. and TokenStream
    • Use https://crates.io/crates/prettyplease to pretty print the whole shebang

    The basic idea:

    1. Assemble lots of small TokenStreams to a large one
    2. Convert TokenStream to &str using https://docs.rs/proc-macro2/1.0.56/proc_macro2/struct.TokenStream.html#method.to_string
    3. Pipe the generated string through https://docs.rs/syn/2.0.15/syn/fn.parse_file.html to generate a https://docs.rs/syn/2.0.15/syn/struct.File.html
    4. Pipe https://docs.rs/syn/2.0.15/syn/struct.File.html through https://docs.rs/prettyplease/0.2.4/prettyplease/fn.unparse.html to have a pretty printed String

    Given this approach of having a TokenStream you get proper error messages, when something is not a legit AST token and you could add your own pretty printer, ...

    If the idea is not clear enough, please ask :)

    enhancement 
    opened by icepuma 4
  • feat: Implement subscription, add firehose examples

    feat: Implement subscription, add firehose examples

    resolves #11

    • Add atrium-xrpc-server member which handles message frames from subscription streams
    • Add examples/firehose, it subscribes and prints all texts of posts
      • ref: https://github.com/bluesky-social/feed-generator/blob/main/src/util/subscription.ts
    • Update codegen and APIs for these subscription messages

    https://github.com/sugyan/atrium/assets/80381/061fb8c4-4cca-4b90-9865-b642dbcd6c45

    opened by sugyan 3
  • Fix broken array URL encoding

    Fix broken array URL encoding

    Switch from serde_urlencoded to a library named serde_qs. serde_urlencoded does not support arrays and has no plan to, so this switches to a fork called serde_qs, which does support common but non-standard query parameters in URLs.

    This was breaking get_posts (and probably others). I tested after and get_posts works now. I initially made the changes to codegen and regenerated atrium-api and tested it after that - but it also picked up some other unrelated changes due to changes to the lexicons, so I revered that and made only the relevant changes manually with sed.

    opened by pmsanford 2
  • Add `is_refresh` argument to atrium-api `XrpcClient::auth`

    Add `is_refresh` argument to atrium-api `XrpcClient::auth`

    I was unable to use refresh_session() and, looking around, I noticed the atrium-xrpc crate's implementation of XrpcClient has an is_refresh parameter to the auth method and a corresponding way to detect refreshes and set that parameter, enabling refreshes. I basically just copied it into the atrium-api version of the trait, which lets me successfully use refresh_session(). I don't think there's a way for refresh_session() to work without this.

    opened by pmsanford 1
  • `atrium_xrpc_server` isn't compatible with `tokio::spawn`

    `atrium_xrpc_server` isn't compatible with `tokio::spawn`

    atrium_xrpc_server::stream::frames::Frame::try_from returns Result<Self, Box<dyn std::error::Error>>. The problem is that dyn std::error::Error is not Send, which means that if the result of Frame::try_from is potentially used across an await, the entire future is not Send.

    To reproduce this, modify the firehose example to spawn the firehose running method instead of running it directly with #[tokio::main]. I tested this at commit 7d99ccd36c8bb562276732d1b9bb888f42530151.

    It would be helpful if the error type was Send + Sync + 'static, to also make it compatible with the anyhow crate. But that can be handled by rewriting the error as a string, whereas the future not being Send is more problematic for usage.

    opened by str4d 1
  • feat: Rewrite codegen

    feat: Rewrite codegen

    resolves #8

    Modified to generate code from proc_macro2::TokenStream using quote and syn. I tried to use prettyplease code formatting, but the indentation was a bit weird, so I decided not to use it. In this project, only I (or a specific user with privileges) execute the lexgen command, so I didn't need to consider the environment without rustfmt or the performance of the execution.

    opened by sugyan 1
  • chore: release

    chore: release

    🤖 New release

    • atrium-api: 0.3.1 -> 0.3.2 (✓ API compatible changes)
    • atrium-cli: 0.1.0
    • atrium-codegen: 0.1.0
    • atrium-lex: 0.1.0
    • atrium-xrpc-server: 0.1.0
    • firehose: 0.1.0
    • atrium: 0.1.0
    Changelog

    atrium-api

    0.3.2 - 2023-06-14

    Other

    • Update atrium_api::xrpc::XrpcClient for refresh

    atrium-cli

    0.1.0 - 2023-05-07

    Other

    • Add like, notifications
    • Update cli/README
    • Add blocks for cli
    • Update cli
    • Add app-password commands to cli
    • Update cli: enable post with reply
    • Add get-record, get-post-thread to cli
    • Add get-author-feed, create-record repost to cli
    • Add Default deriving
    • Update cli
    • Update codegen, use macro
    • Update codegen and api, add create-record to cli
    • Rename project


    This PR was generated with release-plz.

    opened by github-actions[bot] 0
  • chore: release

    chore: release

    🤖 New release

    • atrium-api: 0.3.0 -> 0.3.1 (✓ API compatible changes)
    • atrium-cli: 0.1.0
    • atrium-xrpc: 0.1.0 -> 0.2.0 (⚠ī¸ API breaking changes)
    • atrium-codegen: 0.1.0
    • atrium-lex: 0.1.0
    • atrium-xrpc-server: 0.1.0
    • firehose: 0.1.0
    • atrium: 0.1.0

    ⚠ī¸ atrium-xrpc breaking changes

    --- failure enum_variant_added: enum variant added on exhaustive enum ---
    
    Description:
    A publicly-visible enum without #[non_exhaustive] has a new variant.
            ref: https://doc.rust-lang.org/cargo/reference/semver.html#enum-variant-new
           impl: https://github.com/obi1kenobi/cargo-semver-check/tree/v0.21.0/src/lints/enum_variant_added.ron
    
    Failed in:
      variant Error:SerdeQs in /tmp/.tmp43KpB4/atrium/atrium-xrpc/src/error.rs:77
    
    --- failure enum_variant_missing: pub enum variant removed or renamed ---
    
    Description:
    A publicly-visible enum has at least one variant that is no longer available under its prior name. It may have been renamed or removed entirely.
            ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
           impl: https://github.com/obi1kenobi/cargo-semver-check/tree/v0.21.0/src/lints/enum_variant_missing.ron
    
    Failed in:
      variant Error::SerdeUrlencoded, previously in file /tmp/.tmpvWq5Ll/atrium-xrpc/src/error.rs:77
    
    Changelog

    atrium-api

    0.3.1 - 2023-06-11

    Other

    • Fix broken array URL encoding

    atrium-cli

    0.1.0 - 2023-05-07

    Other

    • Add like, notifications
    • Update cli/README
    • Add blocks for cli
    • Update cli
    • Add app-password commands to cli
    • Update cli: enable post with reply
    • Add get-record, get-post-thread to cli
    • Add get-author-feed, create-record repost to cli
    • Add Default deriving
    • Update cli
    • Update codegen, use macro
    • Update codegen and api, add create-record to cli
    • Rename project

    atrium-xrpc

    0.2.0 - 2023-06-11

    Other

    • Fix reference to serde_qs::ser::Error
    • Fix broken array URL encoding
    • release


    This PR was generated with release-plz.

    opened by github-actions[bot] 0
  • chore: release

    chore: release

    🤖 New release

    • atrium-cli: 0.1.0
    • atrium-xrpc: 0.1.0
    • atrium-codegen: 0.1.0
    • atrium-lex: 0.1.0
    • atrium-xrpc-server: 0.1.0
    • firehose: 0.1.0
    • atrium: 0.1.0
    Changelog

    atrium-cli

    0.1.0 - 2023-05-07

    Other

    • Add like, notifications
    • Update cli/README
    • Add blocks for cli
    • Update cli
    • Add app-password commands to cli
    • Update cli: enable post with reply
    • Add get-record, get-post-thread to cli
    • Add get-author-feed, create-record repost to cli
    • Add Default deriving
    • Update cli
    • Update codegen, use macro
    • Update codegen and api, add create-record to cli
    • Rename project

    atrium-xrpc

    0.1.0 - 2023-06-07

    Added

    • update xrpc

    Other

    • Update atrium-api to 0.3
    • Update README
    • Update cli
    • Update codegen, use macro
    • Update codegen and api, add create-record to cli
    • Rename project


    This PR was generated with release-plz.

    opened by github-actions[bot] 0
  • chore: release

    chore: release

    🤖 New release

    • atrium-api: 0.2.0 -> 0.3.0 (⚠ī¸ API breaking changes)
    • atrium-cli: 0.1.0
    • atrium-xrpc: 0.1.0
    • atrium-codegen: 0.1.0
    • atrium-lex: 0.1.0
    • atrium-xrpc-server: 0.1.0
    • firehose: 0.1.0
    • atrium: 0.1.0

    ⚠ī¸ atrium-api breaking changes

    --- failure constructible_struct_adds_field: externally-constructible struct adds field ---
    
    Description:
    A pub struct constructible with a struct literal has a new pub field. Existing struct literals must be updated to include the new field.
            ref: https://doc.rust-lang.org/reference/expressions/struct-expr.html
           impl: https://github.com/obi1kenobi/cargo-semver-check/tree/v0.20.1/src/lints/constructible_struct_adds_field.ron
    
    Failed in:
      field RepoOp.cid in /tmp/.tmpLCrufW/atrium/atrium-api/src/com/atproto/sync/subscribe_repos.rs:57
      field Commit.blobs in /tmp/.tmpLCrufW/atrium/atrium-api/src/com/atproto/sync/subscribe_repos.rs:10
      field Commit.blocks in /tmp/.tmpLCrufW/atrium/atrium-api/src/com/atproto/sync/subscribe_repos.rs:13
      field Commit.commit in /tmp/.tmpLCrufW/atrium/atrium-api/src/com/atproto/sync/subscribe_repos.rs:14
      field Commit.prev in /tmp/.tmpLCrufW/atrium/atrium-api/src/com/atproto/sync/subscribe_repos.rs:17
    
    --- failure enum_variant_added: enum variant added on exhaustive enum ---
    
    Description:
    A publicly-visible enum without #[non_exhaustive] has a new variant.
            ref: https://doc.rust-lang.org/cargo/reference/semver.html#enum-variant-new
           impl: https://github.com/obi1kenobi/cargo-semver-check/tree/v0.20.1/src/lints/enum_variant_added.ron
    
    Failed in:
      variant ActionViewDetailSubjectEnum:RepoViewNotFound in /tmp/.tmpLCrufW/atrium/atrium-api/src/com/atproto/admin/defs.rs:226
      variant ActionViewDetailSubjectEnum:RecordViewNotFound in /tmp/.tmpLCrufW/atrium/atrium-api/src/com/atproto/admin/defs.rs:230
      variant ViewRecordEnum:AppBskyFeedDefsGeneratorView in /tmp/.tmpLCrufW/atrium/atrium-api/src/app/bsky/embed/record.rs:64
      variant Record:AppBskyFeedGenerator in /tmp/.tmpLCrufW/atrium/atrium-api/src/records.rs:9
      variant Error:RepoNotFound in /tmp/.tmpLCrufW/atrium/atrium-api/src/com/atproto/admin/get_repo.rs:29
      variant ReportViewDetailSubjectEnum:RepoViewNotFound in /tmp/.tmpLCrufW/atrium/atrium-api/src/com/atproto/admin/defs.rs:254
      variant ReportViewDetailSubjectEnum:RecordViewNotFound in /tmp/.tmpLCrufW/atrium/atrium-api/src/com/atproto/admin/defs.rs:258
      variant Error:RecordNotFound in /tmp/.tmpLCrufW/atrium/atrium-api/src/com/atproto/admin/get_record.rs:31
      variant PreferencesItem:SavedFeedsPref in /tmp/.tmpLCrufW/atrium/atrium-api/src/app/bsky/actor/defs.rs:112
    
    Changelog

    atrium-api

    0.3.0 - 2023-05-22

    Added

    • (api) Re-export http in xrpc module
    • (api) Update API from latest lexicon schemas
    • Implement subscription, add firehose examples (#15)

    atrium-cli

    0.1.0 - 2023-05-07

    Other

    • Add like, notifications
    • Update cli/README
    • Add blocks for cli
    • Update cli
    • Add app-password commands to cli
    • Update cli: enable post with reply
    • Add get-record, get-post-thread to cli
    • Add get-author-feed, create-record repost to cli
    • Add Default deriving
    • Update cli
    • Update codegen, use macro
    • Update codegen and api, add create-record to cli
    • Rename project


    This PR was generated with release-plz.

    opened by github-actions[bot] 0
  • [suggestion] Consider making XrpcClient::auth return an owned value

    [suggestion] Consider making XrpcClient::auth return an owned value

    I've written a quick example client to learn about the API. One feature I wanted for my client was to use interior mutability so that the client could refresh its tokens transparently to the consumer, even behind an immutable reference. As you can see, I used a mutex for this - but the fact that auth returns Option<&str> made that pretty difficult. It would also be difficult if you wanted to, for instance, retrieve a token from the environment dynamically in the auth method. My app runs against a branch in my fork that makes the simple change of returning Option<String> instead. You mentioned you were in the middle of refactoring this trait so I thought I'd make this suggestion now.

    Thanks for all the work on this! It's been fun to use.

    opened by pmsanford 1
  • feat: update xrpc interface, add agent, and update API definitions

    feat: update xrpc interface, add agent, and update API definitions

    • Update API (https://github.com/bluesky-social/atproto/commit/4a6c9764e3bc1b9d1a3de9babebde4592ac79dbe)
    • Update atrium_api::xrpc interface, errors
    • Add atrium_api::agent
      • Implement all XRPC traits for this agent
    • Update codegen for these changes
    opened by sugyan 0
  • axum support

    axum support

    Hey, love the work you did so far for atrium. Do you plan on adding axum support for the xrpc-server or what are your plans with this crate?

    Best regards icepuma

    opened by icepuma 4
Releases(atrium-api-v0.3.2)
  • atrium-api-v0.3.2(Jun 14, 2023)

  • atrium-xrpc-v0.2.0(Jun 11, 2023)

  • atrium-api-v0.3.1(Jun 11, 2023)

  • firehose-v0.1.0(May 22, 2023)

  • atrium-xrpc-server-v0.1.0(May 22, 2023)

  • atrium-api-v0.3.0(May 22, 2023)

    Added

    • (api) Re-export http in xrpc module
    • (api) Update API from latest lexicon schemas
    • Implement subscription, add firehose examples (#15)
    Source code(tar.gz)
    Source code(zip)
  • atrium-api-v0.2.0(May 13, 2023)

  • atrium-xrpc-v0.1.0(May 7, 2023)

  • atrium-v0.1.0(May 7, 2023)

  • atrium-lex-v0.1.0(May 7, 2023)

  • atrium-codegen-v0.1.0(May 7, 2023)

  • atrium-cli-v0.1.0(May 7, 2023)

    Other

    • Add like, notifications
    • Update cli/README
    • Add blocks for cli
    • Update cli
    • Add app-password commands to cli
    • Update cli: enable post with reply
    • Add get-record, get-post-thread to cli
    • Add get-author-feed, create-record repost to cli
    • Add Default deriving
    • Update cli
    • Update codegen, use macro
    • Update codegen and api, add create-record to cli
    • Rename project
    Source code(tar.gz)
    Source code(zip)
  • atrium-api-v0.1.1(May 7, 2023)

    What's Changed

    • Error handling by @sugyan in https://github.com/sugyan/atrium/pull/1
    • Update API by @sugyan in https://github.com/sugyan/atrium/pull/2
    • API: Update for publish by @sugyan in https://github.com/sugyan/atrium/pull/3
    • API: Update README, workflows by @sugyan in https://github.com/sugyan/atrium/pull/4
    • Update readme by @sugyan in https://github.com/sugyan/atrium/pull/5
    • Codegen: update codegen, apis by @sugyan in https://github.com/sugyan/atrium/pull/6
    • Add release-plz by @sugyan in https://github.com/sugyan/atrium/pull/7
    • Fix release-plz config by @sugyan in https://github.com/sugyan/atrium/pull/9
    • chore: release by @github-actions in https://github.com/sugyan/atrium/pull/10

    New Contributors

    • @sugyan made their first contribution in https://github.com/sugyan/atrium/pull/1
    • @github-actions made their first contribution in https://github.com/sugyan/atrium/pull/10

    Full Changelog: https://github.com/sugyan/atrium/commits/atrium-api-v0.1.1

    Source code(tar.gz)
    Source code(zip)
Owner
Yoshihiro Sugi
🌲
Yoshihiro Sugi
Tools to feature more lenient Polonius-based borrow-checker patterns in stable Rust

Though this be madness, yet there is method in 't. More context Hamlet: For yourself, sir, shall grow old as I am – if, like a crab, you could go back

Daniel Henry-Mantilla 52 Dec 26, 2022
(lifetime) GATs in stable Rust

::nougat Use (lifetime-)GATs on stable rust. Example #![forbid(unsafe_code)] #[macro_use] extern crate nougat; #[gat] trait LendingIterator { ty

Daniel Henry-Mantilla 45 Dec 26, 2022
Rust crate implementing short & stable ids based on timestamps

Lexicoid Short & stable IDs based on timestamps. Heavily inspired by Short, friendly base32 slugs from timestamps by @brandur. Install Install with ca

Luciano Mammino 6 Jan 29, 2023
A traditional web forum built in Rust with modern technology to be fast, secure, scalable, and stable.

Volksforo A traditional web forum built in Rust with modern technology to be fast, secure, scalable, and stable. Stack Rust actix-web askama ScyllaDB

Josh 5 Mar 21, 2023
This is a lightweight audio-video player built in Rust using FFmpeg libraries. It demonstrates the usage of FFmpeg with Rust to play back video files.

FFmpeg Rust Video Player This is a lightweight audio-video player built in Rust using FFmpeg libraries. It demonstrates the usage of FFmpeg with Rust

Jenin Sutradhar 3 Apr 10, 2024
Additional Rust collections not found in std::collections

More collections Rust crate with additional collections not found in std::collections. Multimaps Completion Name Behaves like ?? ?? ?? âŦœī¸ âŦœī¸ HashSetMu

Rinde van Lon 4 Dec 21, 2022
Indeed, an ORM library, not a framework, written in Rust

Ormlib Indeed, an ORM library, not a framework, written in Rust Features The main idea that I put into my ORM library is a minimum of stupid code and

Evgeny Igumnov 5 Sep 4, 2023
memchr vs stringzilla - up to 7x throughput difference between two SIMD-accelerated substring search libraries in Rust

memchr vs stringzilla Rust Substring Search Benchmarks Substring search is one of the most common operations in text processing, and one of the slowes

Ash Vardanian 38 Mar 5, 2024
A special rope, designed to work with any data type that is not String

AnyRope AnyRope is an arbitrary data type rope for Rust, designed for similar operations that a rope would do, but targeted at data types that are not

ahoyiski 27 Mar 22, 2023
📁 A not-so-true-to-life implementation of .env (dot env) for gmod

gmsv_dot_env A not-so-true-to-life implementation of a .env file for gmod. Place a .env at ./garrysmod/.env and any variables set in it will be access

Owain 12 Feb 14, 2023
Yet another trojan-gfw in Rust

Trojan-rust Yet another trojan-gfw implementation in Rust. Features Server mode only (for now). Supports Redis auth & flow stat. Uses OpenSSL as crypt

į˛’į˛’抙 34 Oct 25, 2022
Rust bindings to the Wolfram Symbolic Transport Protocol (WSTP)

wstp Bindings to the Wolfram Symbolic Transfer Protocol (WSTP) library. This crate provides a set of safe and ergonomic bindings to the WSTP library,

Wolfram Research, Inc. 10 Nov 1, 2022
Rust lib for fetching official protoc (Protocol Buffer compiler) releases

protoc-fetcher Rust library for fetching official Protocol Buffer compiler (protoc) releases, pegged to a specific version. protoc-fetcher downloads a

Arcanyx Technical Wizardry LLC 2 Sep 5, 2022
SDK for the Portfolio protocol written in rust.

portfolio-rs Minimalist toolkit for building rust applications on top of the portfolio protocol. Installation [Required] Foundry. Source. If not insta

Primitive 5 Aug 14, 2023
Precio is a Rust library that implements the Precio protocol for computing private layered histograms and sums.

Overview of Precio Precio is a Rust implementation of the protocol described in eprint.iacr.org/2021/1490. The goal of the protocol is to enable an an

Microsoft 9 Aug 16, 2023
Manas project aims to create a modular framework and ecosystem to create robust storage servers adhering to Solid protocol in rust.

ā¤Žā¤¨ā¤¸āĨ | Manas Solid is a web native protocol to enable interoperable, read-write, collaborative, and decentralized web, truer to web's original vision.

Manomayam 17 Oct 5, 2023
A learning project/fun experiment in internet protocol

Piper a learning project/fun experiment in internet protocol Version 0.4.0 (SEMVER) Goals Piper is Simple. A page is a page. There are no secondary re

null 13 Oct 27, 2022
Simple and fast proxy checker that include protocol validation;

Open Proxies ⭐ī¸ Leave me a start please ⭐ī¸ it will motivate me to continue maintaining and adding futures About | Technologies | Requirements | Starti

kmoz000 3 Nov 29, 2022
Leetcode Solutions in Rust, Advent of Code Solutions in Rust and more

RUST GYM Rust Solutions Leetcode Solutions in Rust AdventOfCode Solutions in Rust This project demostrates how to create Data Structures and to implem

Larry Fantasy 635 Jan 3, 2023