scheme

Function scheme 

Source
pub fn scheme(s: &str) -> Result<(), Error>
Expand description

Validates IRI scheme.

Note that this function does not accept a trailing colon.

Also note that the syntax of the scheme is common between RFC 3986 (URIs) and RFC 3987 (IRIs).

ยงExamples

use iri_string::validate::scheme;
assert!(scheme("https").is_ok());
assert!(scheme("file").is_ok());
assert!(scheme("git+ssh").is_ok());

// Colon is syntactically not part of the scheme.
assert!(scheme("colon:").is_err());
// Scheme cannot be empty.
assert!(scheme("").is_err());
// The first character should be alphabetic character.
assert!(scheme("0abc").is_err());
assert!(scheme("+a").is_err());
assert!(scheme("-a").is_err());