Comments (3)
Sure, atrium-repo
sounds good. I'll open a PR with the initial implementation.
from atrium.
I've written code for MST and repo parsing myself for a CAR viewer project, on top of atrium-api
and libipld
(but will be migrating it to ipld-core
soon). I'd be happy to upstream it here if we can decide where it should go.
The current APIs I have are:
struct Repository<R: tokio::io::AsyncRead + tokio::io::AsyncSeek> { .. }
impl<R: AsyncRead + AsyncSeek + Unpin + Send> Repository<R> {
async fn load(reader: R) -> Result<Self, _> { .. }
fn did(&self) -> &Did { .. }
fn keys<'a>(&'a mut self) -> impl Stream<Item = Result<String, _>> + 'a { .. }
fn get_collection<'a, C: Collection + 'a>(
&'a mut self,
) -> impl futures::Stream<Item = Result<(RecordKey, C::Record), _>> + 'a { .. }
fn get_collection_reversed<'a, C: Collection + 'a>(
&'a mut self,
) -> impl futures::Stream<Item = Result<(RecordKey, C::Record), _>> + 'a { .. }
async fn get<C: Collection>(
&mut self,
rkey: &RecordKey,
) -> Result<Option<C::Record>, _> { .. }
}
mod mst {
enum Located<E> {
Entry(E),
InSubtree(Cid),
}
struct Node { .. }
impl Node {
fn parse(bytes: &[u8]) -> Result<Option<Self>, _> { .. }
fn get(&self, key: &[u8]) -> Option<Located<Cid>> { .. }
fn entries_with_prefix<'a>(
&'a self,
prefix: &'a [u8],
) -> impl Iterator<Item = Located<(&[u8], Cid)>> + 'a { .. }
fn reversed_entries_with_prefix<'a>(
&'a self,
prefix: &'a [u8],
) -> impl Iterator<Item = Located<(&[u8], Cid)>> + 'a { .. }
}
}
I went with async APIs because I'm reading a CAR file from disk. For firehose subscribers maybe sync APIs would be fine, but given that the crates in this repo already have async APIs, I figure this works fine as a starting point.
from atrium.
Thanks for the suggestion!
I hadn't considered implementing something about that yet, but if you would like to add it, Iām very welcome to merge them.
Would it be better to add it as a new package, like atrium-repo
(named from @atporoto/repo
in reference to the original TypeScript implementation)?
Also, as you may have noticed, we are trying to add some new libraries in atrium-libs
in #166, but this is still a draft. I am adding implementations little by little now and may eventually split each into separate packages.
from atrium.
Related Issues (20)
- Subscribe repos example? HOT 6
- wasm32 support? HOT 3
- Progress update / coverage? HOT 2
- Remove support for surf HTTP client
- types of atrium-api
- logo image HOT 4
- Error on atrium-cli get-timeline HOT 2
- Labels and moderation functions for AtpAgent
- Upgrade to version 1.0 of the http crate?
- Introduction of Builders
- Add new string formats
- `app.bsky.feed.getPosts` fails with more than a certain number of arguments `uris`
- Deserializing embed messages from subscriptions HOT 7
- axum support HOT 4
- `atrium_xrpc_server` isn't compatible with `tokio::spawn` HOT 1
- [suggestion] Consider making XrpcClient::auth return an owned value HOT 2
- reqwest with rusttls feature flag HOT 1
- Plans for an atrium PDS? HOT 4
- Suggestion: Change code writer HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
š Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ššš
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ā¤ļø Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from atrium.