A client sending Accept: application/x-protobuf gets protobuf, and one sending Content-Type: application/x-protobuf may send its body so; JSON stays the default, so the page, the TUI and older iOS builds see nothing new. ipx's own calls to the directory and ipx-play now go in protobuf. The handlers are untouched. A new crate, ipx-wire, holds the .proto files (compiled by protox in build.rs, so no protoc anywhere) and one layer, negotiate, that converts JSON at the edge through prost-reflect, by a table of each route's messages. Writing prost structs beside every serde one would have doubled each type and every handler. Protobuf cannot tell absent from empty or from null, and the PATCH bodies depend on that: an Option<Vec> left out leaves the list, an empty one clears it, and null clears a folder. So a list in a body is a one-field message (absent or present), and null-to-clear is a google.protobuf.Value. Numbers in a Value come back whole, or 3.0 would not read as a usize. Debug builds convert every JSON answer strictly and answer 500 for a field missing from the .proto or a route missing from a table; the cargo tests and the browser suite (125 tests) ran clean that way. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
26 lines
682 B
Protocol Buffer
26 lines
682 B
Protocol Buffer
// ipx-play's API (crates/play/src/lib.rs), each message named after the Rust struct it mirrors.
|
|
// A field added there goes here too; debug builds refuse an answer with a field missing here.
|
|
syntax = "proto3";
|
|
package play;
|
|
|
|
// POST /v1/shares, the body.
|
|
message Episode {
|
|
string feed_url = 1;
|
|
string guid = 2;
|
|
optional string feed_title = 3;
|
|
optional string feed_image = 4;
|
|
optional string title = 5;
|
|
optional string description = 6;
|
|
optional string link = 7;
|
|
optional int64 published = 8;
|
|
optional int64 duration = 9;
|
|
string audio_url = 10;
|
|
optional string mime = 11;
|
|
}
|
|
|
|
// POST /v1/shares, the answer.
|
|
message Shared {
|
|
string id = 1;
|
|
string url = 2;
|
|
}
|