Hey team, is there any Rust :rust:
# spicedb
y
Hey team, is there any Rust client you recommend to use? the list under https://github.com/authzed/awesome-spicedb they are either archived, or they do not have any updates for more than 2 years, which hopefully means it is good
this is the most recent one i've seen
though i don't have much experience with rust so i don't know how to evaluate it
y
Any reason for Authzed to avoid owning a official one?
y
just hasn't been a priority yet 🤷 we don't have any explicit aversion to it
y
y
i will say that you'd get 90% of the way there by generating your own client code using the authzed proto and the appropriate protoc plugin
y
btw, the one you shared, really good one, very small, to the point
y
i'd guess that the old/unmaintained crates are probably missing some of the newer APIs if they haven't been regenerated recently
and otherwise the additional functionality in our libs tends to be a small helper to set up credentials
y
yeah, it is just protoc, whcih is good, just small things on top for building the conn and small thing slike that
y
ye
y
still, it is such tiny thing thou, that, I would prefer to use it from the official list, all about security and not having to explain to Enterprise things 😉
no even about coding
y
yeah, heard
y
I am gonna end up migrating to Go because of that ... (this is my first time in Rust) so many things are just all over the place and compared to Go ... bois so much work
Then I remember nil interfaces and the pain goes away
thank you thou, very helpful, I think I am gonna end up just writing my own
j
we might have an improved one coming in a bit
y
@Joey where !!!!!!!!!
Dont do this to me! I was about to do what the person above did, just using
buf
and, well, no external so I dont have to deal with trusting releases
j
we're still testing some ideas
y
what the person did is quite close to what I would done 100%
j
yetitwo? that's my coworker 🙂
y
@Joey you will have to hire me!!!! $1 a month! dont do this to me!

https://tenor.com/5LZw.gifâ–¾

j
does this look... reasonable?
Copy code
let client = SpiceDBClient::new_plaintext("localhost:50051", "somerandomkeyhere")
        .await
        .expect("failed to create client");

    // Write schema
    client
        .write_schema(SCHEMA)
        .await
        .expect("write schema failed");

    // Write test data: alice is a viewer of firstdoc
    let rel = Relationship::new("document", "firstdoc", "viewer", "user", "alice", "")
        .expect("invalid relationship");
    let mut txn = Transaction::new();
    txn.touch(&rel);
    let revision = client.write(&txn).await.expect("write relationships failed");

    // Check permission: alice should be able to view firstdoc
    let check_rel = Relationship::new("document", "firstdoc", "view", "user", "alice", "")
        .expect("invalid relationship");
    let result = client
        .check_permission(&consistency::at_least(&revision), "view", &check_rel)
        .await
        .expect("check failed");

    println!("alice can view document:firstdoc: {}", result.has_permission);
    assert!(result.has_permission, "expected alice to have view permission");
y
personally, I prefer 1 struct in and 1 struct out, too many position parameters to mess up
it would be almost just the underlying gRPC type, honestly, you dont need to complicate that part, Just the connection struct with a nice builder pattern and mov eon
UNLESS, they are some client-specific fixes you do for the user because of whatever protocol, fine, wrap the underlying gRPC message into your own message
j
there are a few, in theory
we're discussing different designs
y
Right, for those, you can convert into those types from the gRPC, or built-in so people dont ever see it. I like to keep things composible, so I normally have both, as a spacegoat, but provide yet the other wrapping union layer avoid the mistakes
u
Hey Yordis, We currently use spicedb on a huge rust codebase for distributed systems requiring security hardening. After some triage to understand what works and what doesn't, we found that spicedb-rust crate alone was not a good fit for us because it was not supporting edge cases we had and was quite outdated. Eventually we made the decision to go with building the protobufs provided by spicedb and leveraging them in our rust environment which let us do pretty much do everything we need to. It's not really hard / time consuming to build a small client that works straight off the bat if you consider that you may need some of the latest features from spicedb available right away. To give you an idea our client definition is only ~100 lines-long and we use it all the time. Hope that helps in your decision-making !
31 Views