frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

Ask HN: Is this a sane way to expose distributed state in Rust?

1•asdfghjqwertyu•2h ago
Hi HN,

I’m experimenting with a Rust runtime that exposes replicated, consensus-backed state by advertising a *procedural macro*. Client crates invoke the macro and get a typed API; the runtime owns both the protocol and the codegen.

At a high level, the DB cell:

* Handles RPC (Upsert / Get / Remove) * Coordinates macro expansion for client APIs * Stores opaque zero-copy blobs (`rkyv`)

Here’s the core of the DB side:

```rust use cell_sdk::; use cell_model::macro_coordination::; use std::pin::Pin;

#[protein] pub struct Upsert { pub key: u64, pub kind: String, pub blob: Vec<u8>, }

#[protein] pub struct Get { pub key: u64, pub kind: String }

#[protein] pub struct Row { pub blob: Option<Vec<u8>> }

#[service] #[derive(Clone)] struct DbService { state: Arc<RwLock<HashMap<(u64, String), Vec<u8>>>>, }

#[handler] impl DbService { async fn upsert(&self, u: Upsert) -> Result<bool> { self.state.write().await.insert((u.key, u.kind), u.blob); Ok(true) } async fn get(&self, g: Get) -> Result<Row> { let val = self.state.read().await.get(&(g.key, g.kind)).cloned(); Ok(Row { blob: val }) } async fn remove(&self, k: u64, kind: String) -> Result<bool> { Ok(self.state.write().await.remove(&(k, kind)).is_some()) } }

fn expand_table(ctx: &ExpansionContext) -> Pin<Box<dyn Future<Output=Result<String>> + Send + '_>> { Box::pin(async move { let struct_name = &ctx.struct_name; let pk = ctx.fields.first().unwrap().0.clone();

        Ok(format!(r#"
            pub struct {struct_name}Table {{ synapse: ::cell_sdk::Synapse }}
            impl {struct_name}Table {{
                pub async fn connect() -> ::anyhow::Result<Self> {{
                    Ok(Self {{ synapse: ::cell_sdk::Synapse::grow("db").await? }})
                }}
                pub async fn save(&self, row: {struct_name}) -> ::anyhow::Result<bool> {{
                    let bytes = ::cell_sdk::rkyv::to_bytes::<_,1024>(&row)?.into_vec();
                    let req = DbProtocol::Upsert {{
                        key: row.{pk},
                        kind: "{struct_name}".into(),
                        blob: bytes,
                    }};
                    self.synapse.fire(&req).await
                }}
            }}
        "#))
    })
}

#[tokio::main] async fn main() -> Result<()> { let db = DbService { state: Default::default() };

    const macros = vec![MacroInfo {
        name: "table".into(),
        kind: MacroKind::Attribute,
        description: "distributed table".into(),
        dependencies: vec![],
    }];

    Runtime::ignite_with_coordination(
        move |req| db.dispatch(req),
        "db",
        macros,
        expand_table,
    ).await
} ```

consumer

```rust use cell_sdk::;

#[expand("db", "table")] #[derive(Archive, Serialize, Clone, Debug)] pub struct Order { pub order_id: u64, pub user_id: u64, pub amount: u64, }

#[tokio::main] async fn main() -> anyhow::Result<()> { let orders = OrderTable::connect().await?;

    orders.save(Order { order_id: 42, user_id: 7, amount: 1000 }).await?;
    let o = orders.get(42).await?.unwrap();
    println!("loaded {o:?}");

    orders.remove(42).await?;
    Ok(())
} ```

The question: *does letting a distributed service own both its protocol and client-side macro make sense, or is this hiding too much complexity?* And: Would this actually be useful for enterprise? Would you use it?

Thanks — looking for design-level feedback, not users.

Deno 2.6 and Socket: Supply Chain Defense in Your CLI

https://socket.dev/blog/deno-2-6-socket-supply-chain-defense-in-your-cli
2•feross•2m ago•0 comments

Battery storage hits $65/MWh, a tipping point for solar

https://electrek.co/2025/12/12/battery-storage-hits-65-mwh-tipping-point-solar/
3•toomuchtodo•9m ago•1 comments

EV sticker shock: Solo drivers using California carpool lanes face hefty fines

https://www.latimes.com/california/story/2025-12-01/ev-sticker-shock-solo-drivers-using-californi...
1•PaulHoule•10m ago•0 comments

Show HN: I made a grid that sizes your subscriptions by what they cost

https://visualize.nguyenvu.dev/
1•hoangvu12•11m ago•1 comments

UK Lords propose ban on VPNs for children

https://www.techradar.com/vpn/vpn-privacy-security/uk-lords-propose-ban-on-vpns-for-children
1•josephcsible•12m ago•0 comments

Google Removes Sci-Hub Domains from U.S. Search Results Due to Dated Court Order

https://torrentfreak.com/google-removes-sci-hub-domains-from-u-s-search-results-due-to-dated-cour...
2•t-3•13m ago•0 comments

Processing 630M More Pwned Passwords, Courtesy of the FBI

https://www.troyhunt.com/processing-630-million-more-pwned-passwords-courtesy-of-the-fbi/
1•LorenDB•14m ago•0 comments

Waymo: "Not yet a legal path to operating in New York"; NYC demo video

https://twitter.com/Waymo/status/1999620430970167481
1•tech234a•15m ago•0 comments

Cycle-accurate YM2149 PSG emulator

https://github.com/slippyex/ym2149-rs
1•todsacerdoti•17m ago•0 comments

The Coming Need for Formal Specification

https://benjamincongdon.me/blog/2025/12/12/The-Coming-Need-for-Formal-Specification/
1•todsacerdoti•18m ago•0 comments

.NET Wrapper for latest PCRE2 library

https://github.com/ltrzesniewski/pcre-net
1•hooge•21m ago•0 comments

Oliver Sacks fabricated key details in his books

https://boingboing.net/2025/12/12/oliver-sacks-fabricated-key-details-in-his-books.html
2•talonx•22m ago•0 comments

Fairly Trained AI

https://www.fairlytrained.org
1•pabs3•22m ago•0 comments

Meta's Pivot from Open Source to Money-Making AI Model

https://www.bloomberg.com/news/articles/2025-12-10/inside-meta-s-pivot-from-open-source-to-money-...
2•gmays•23m ago•0 comments

Papermoon: A Space-Grade Linux for the NewSpace Era

https://thenewstack.io/papermoon-a-space-grade-linux-for-the-newspace-era/
1•CrankyBear•25m ago•0 comments

A Lisp Interpreter Implemented in Conway's Game of Life (2022)

https://woodrush.github.io/blog/posts/2022-01-12-lisp-in-life.html
1•pabs3•28m ago•0 comments

Redis-rs and Redis-test 1.0.0

https://github.com/redis-rs/redis-rs/blob/main/version1.md
1•stmw•38m ago•0 comments

1300 Still Images from the Animated Films of Hayao Miyazaki's Studio Ghibli

https://www.ghibli.jp/info/013772/
3•vinhnx•38m ago•0 comments

Visualizing the 4th Dimension with WebGPU

https://dugas.ch/funderstanding/visualizing_the_4th_dimension.html
1•chronolitus•39m ago•1 comments

Visual Proof of Pythagoras' Theorem [video]

https://www.youtube.com/watch?v=tTHhBE5lYTg
2•thunderbong•41m ago•1 comments

Roundup of Events for Bootstrappers in December 2025

https://bootstrappersbreakfast.com/2025/11/25/roundup-of-december-2025-bootstrapper-events/
1•skmurphy•47m ago•1 comments

How the Team Behind Valkey Knew It Was Time to Fork

https://thenewstack.io/how-the-team-behind-valkey-knew-it-was-time-to-fork/
1•CrankyBear•49m ago•0 comments

Searching: Cybersecurity Classes

2•prospopa•52m ago•0 comments

Man shocks doctors with 254/150 blood pressure, stroke from energy drinks

https://arstechnica.com/health/2025/12/man-shocks-doctors-with-extreme-blood-pressure-stroke-from...
3•canucker2016•53m ago•1 comments

The unlikely photo that kickstarted the social web (2016)

https://www.bbc.com/future/article/20160224-the-unlikely-photo-that-kickstarted-the-social-internet
1•1659447091•54m ago•0 comments

The Bet on Juniors Just Got Better

https://tidyfirst.substack.com/p/the-bet-on-juniors-just-got-better
2•gmays•55m ago•1 comments

Three Dogs Stroll

https://old.reddit.com/r/Pareidolia/comments/1jd5fro/three_dogs_stroll/
4•susam•59m ago•0 comments

JPM the Java Package Manager

1•sunnykentz•1h ago•0 comments

We unpack the journey from pivot hell to product-market fit [video]

https://www.youtube.com/watch?v=X1_WTh3Sm4c
1•rchachra•1h ago•0 comments

Lite^3, a JSON-Compatible Zero-Copy Serialization Format

https://github.com/fastserial/lite3
3•cryptonector•1h ago•1 comments