1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//! An implementation of the
//! [Guppy protocol](https://github.com/dimkr/guppy-protocol) v0.4.4
//! (`guppy://`, UDP port 6775): an async client and server with chunking,
//! per-packet acknowledgement, and retransmission, plus a small CLI.
//!
//! Guppy is dimkr's smolweb-over-UDP protocol, inspired by TFTP, DNS, and
//! Spartan. A request is a single datagram carrying a URL (user input rides
//! the query component, percent-encoded). The server answers with either a
//! special single-digit packet — `1 <prompt>` / `3 <url>` redirect /
//! `4 <error>` — or a **success** packet `<seq> <mimetype>\r\n<data>` whose
//! sequence number starts at a random value in `[6, 2^31-1]`, followed by
//! continuation packets `<seq>\r\n<data>` (seq incrementing by one), ended by
//! an empty continuation (the end-of-file packet). The client acknowledges
//! every success/continuation/EOF packet by echoing its sequence number.
//! Lost packets are handled by retransmission on both sides.
//!
//! This crate is independent and unaffiliated with the protocol's author.
//! The crates.io name is qualified (`guppy-protocol`) because the bare
//! `guppy` name is used by an unrelated project.
//!
//! ```no_run
//! # async fn run() -> Result<(), guppy_protocol::ClientError> {
//! use guppy_protocol::{GuppyResponse, fetch};
//!
//! match fetch("guppy://guppy.mozz.us/", &Default::default()).await? {
//! GuppyResponse::Success { mime, body } => {
//! println!("{} bytes of {mime}", body.len());
//! }
//! other => println!("{other:?}"),
//! }
//! # Ok(()) }
//! ```
/// Guppy's default port ('gu').
pub const GUPPY_PORT: u16 = 6775;
/// The spec's request-size ceiling: the URL plus the trailing CRLF must fit
/// in 2048 bytes.
pub const MAX_REQUEST_BYTES: usize = 2048;
/// The largest sequence number (maximum value of a signed 32-bit integer).
pub const MAX_SEQ: u32 = 2_147_483_647;
/// The smallest first-packet sequence number.
pub const MIN_SEQ: u32 = 6;
pub use ;
pub use ;
pub use ;
/// A complete guppy response, as returned by the client.