refactor(shared): move REST wire types into the shared crate #105
No reviewers
Labels
No labels
area:api
area:core
area:docs
area:infra
area:ux
dependencies
documentation
duplicate
good first issue
help wanted
invalid
question
rust
status:complete
status:partial
status:planned
type:bug
type:design
type:feature
type:infra
type:refactor
type:refactor
type:research
type:ux
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
icub3d/decentcom!105
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feature/82-shared-rest-types"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Every REST request/response body was hand-duplicated between
server/src/**/models.rsandsdk/rust/src/rest/models.rs(whose own doc-comment admitted the two "must stay in lockstep"). Because serde silently ignores unknown fields, drift produced no compile error — just missing data on the wire.What this does (checkboxes 1, 2, 3, 5)
shared::restwith#[derive(Serialize, Deserialize)]. Request types keep theirskip_serializing_if(SDK side) and the three-valuedOption<Option<String>>deserialize_withvisitor (server side) merged onto one struct — each attribute only affects the end that uses it.server/src/**/models.rsnow re-export the shared types under their existing*Responsenames and keep only the storage→wireFromimpls. The two inherent constructors that can't be attached to a foreign type (MessageResponse::from_message,InviteResponse::from_invite) become free functionsmessage_response/invite_response.sdk/rust/src/rest/models.rscollapses from ~370 lines to a singlepub use shared::rest::….ProfileResponse/RoleSummary/UpdateProfileRequest.ClientCommandenum instead of raw"SUBSCRIBE"/"UNSUBSCRIBE"/"HEARTBEAT_ACK"string literals.ClientCommandgained a wire-formatSerialize(the derived one was externally-tagged and wrong), so encode and decode share one source of truth for the op strings.No JSON field names,
#[serde(rename)]s, or status codes change — this is wire-compatible.Deferred to a follow-up (checkbox 4)
Unifying gateway event payload types between the server broadcaster and bot-sdk. That requires per-op reconciliation of what the server broadcasts vs. what bot-sdk decodes (e.g.
MemberJoin's payload vs. the fullMember) and changes bot-sdk's publicEventpayload types, so it's a distinct, riskier unit.Verification
cargo build --workspace— cleancargo clippy --workspace --all-targets -- -D warnings— cleancargo test --workspace— all pass (server 130, shared 9 incl. new three-valued + client-command roundtrip tests, SDK 8, bot-sdk green)Net −205 lines.
Part of #82
🤖 Generated with Claude Code