Skip to main content

forge_primitives/
wire.rs

1//! The socket's binary frame tags, shared by every Rust half that speaks it.
2
3/// The binary kind a compressed JSON frame crosses as.
4///
5/// Kinds 0, 1 and 2 are a dictation frame, a browser frame and its audio, all
6/// `forge-server`'s own. This one is a whole `ServerMessage` body, gzipped,
7/// for a client that declared `deflate=1` on its socket URL: the server's
8/// connection builds it and the shell's socket decodes it, so the tag lives
9/// here rather than as a copy in each.
10pub const COMPRESSED_JSON_TAG: u8 = 3;
11
12#[cfg(test)]
13mod tests {
14    use super::COMPRESSED_JSON_TAG;
15
16    /// `client/src/socket.ts` keeps its own copy of this tag, because a page
17    /// is not a Rust half. Renumbering the tag here without that copy is a
18    /// frame no browser can read.
19    #[test]
20    fn the_compressed_tag_is_the_one_the_web_page_hardcodes() {
21        assert_eq!(COMPRESSED_JSON_TAG, 3);
22    }
23}