diff options
author | Richard Walters <rwalters@digitalstirling.com> | 2020-10-13 01:09:18 -0700 |
---|---|---|
committer | Richard Walters <rwalters@digitalstirling.com> | 2020-10-13 01:09:18 -0700 |
commit | dc2a011598f4aa9e9de927333e467e623276d5ec (patch) | |
tree | 4b5c71634af516cdc96c512f28a02370d48c25b3 /src/context.rs | |
parent | 4accf8c296ef7a1f6bd10a90b7a06b3b499ccda6 (diff) |
Rust refactoring
* Move Context, Error, and character classes to their own modules.
* Move host/port parsing and IP address validation to their
own modules, and break the code up into different functions
to process their state machines.
Diffstat (limited to 'src/context.rs')
-rw-r--r-- | src/context.rs | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/context.rs b/src/context.rs new file mode 100644 index 0000000..ef8c7cb --- /dev/null +++ b/src/context.rs @@ -0,0 +1,48 @@ +#![warn(clippy::pedantic)] + +#[derive(Debug, Clone, Copy, PartialEq)] +pub enum Context { + Fragment, + Host, + Ipv4Address, + Ipv6Address, + IpvFuture, + Path, + Query, + Scheme, + Userinfo, +} + +impl std::fmt::Display for Context { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Context::Fragment => { + write!(f, "fragment") + }, + Context::Host => { + write!(f, "host") + }, + Context::Ipv4Address => { + write!(f, "IPv4 address") + }, + Context::Ipv6Address => { + write!(f, "IPv6 address") + }, + Context::IpvFuture => { + write!(f, "IPvFuture") + }, + Context::Path => { + write!(f, "path") + }, + Context::Query => { + write!(f, "query") + }, + Context::Scheme => { + write!(f, "scheme") + }, + Context::Userinfo => { + write!(f, "user info") + }, + } + } +} |