iref 4.0.0

Uniform & Internationalized Resource Identifiers (URIs/IRIs), borrowed and owned.
Documentation
/// This file is auto-generated by `static-automata`. Do not edit.
pub struct Scheme {
	state: u32,
}
impl Scheme {
	pub const fn new() -> Self {
		Self { state: 0u32 }
	}
	pub const fn push(&mut self, token: char) -> bool {
		self.state = match self.state {
			0u32 => match token {
				'A'..='Z' | 'a'..='z' => 1u32,
				_ => return false,
			},
			1u32 => match token {
				'+' | '-'..='.' | '0'..='9' | 'A'..='Z' | 'a'..='z' => 1u32,
				_ => return false,
			},
			_ => return false,
		};
		true
	}
	pub const fn is_accepting(&self) -> bool {
		matches!(self.state, 1u32)
	}
	pub const fn validate_str(s: &str) -> bool {
		Self::validate_bytes(s.as_bytes())
	}
	pub const fn validate_bytes(bytes: &[u8]) -> bool {
		let mut i = 0;
		let mut automaton = Self::new();
		while i < bytes.len() {
			match ::static_automata::decode_utf8_char(bytes, i) {
				Ok((c, len)) => {
					if !automaton.push(c) {
						return false;
					}
					i += len;
				}
				Err(_) => return false,
			}
		}
		automaton.is_accepting()
	}
}
pub struct Port {
	state: u32,
}
impl Port {
	pub const fn new() -> Self {
		Self { state: 0u32 }
	}
	pub const fn push(&mut self, token: char) -> bool {
		self.state = match self.state {
			0u32 => match token {
				'0'..='9' => 0u32,
				_ => return false,
			},
			_ => return false,
		};
		true
	}
	pub const fn is_accepting(&self) -> bool {
		matches!(self.state, 0u32)
	}
	pub const fn validate_str(s: &str) -> bool {
		Self::validate_bytes(s.as_bytes())
	}
	pub const fn validate_bytes(bytes: &[u8]) -> bool {
		let mut i = 0;
		let mut automaton = Self::new();
		while i < bytes.len() {
			match ::static_automata::decode_utf8_char(bytes, i) {
				Ok((c, len)) => {
					if !automaton.push(c) {
						return false;
					}
					i += len;
				}
				Err(_) => return false,
			}
		}
		automaton.is_accepting()
	}
}