FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    UriRef

    enum · ferroui-base · v0.5.0

    enum UriRef
    

    A URI reference (RFC 3986, section 4.1): an absolute URL, or a reference relative to a base URL.

    Equality and hashing are the ones of url::Url for an absolute reference, with the fragment (decision O5 of docs/idiomatic-rust-signatures.md: resm:A.B#Name is not resm:A.B), and the text for a relative one; an absolute reference never equals a relative one. Uri compares absolute URIs without their fragment, as .NET does: a map that needs that rule keys by without_fragment explicitly.

    The text of a URL is the one of the URL standard: the special schemes (http, https, file, ...) are normalised (http://host is http://host/, default ports and dot segments go, characters outside the allowed set are percent-encoded); the schemes of the framework (ferres://, fonts:, resm:) and file:// URLs keep their text.

    View source

    Members

    Absolute

    Absolute(url::Url)
    

    An absolute URL.

    Source

    Relative

    Relative(Box<str>)
    

    A reference relative to a base URL, as written.

    Source

    parse

    fn parse(text: &str) -> Result<Self, url::ParseError>
    

    Parses a URI reference with the rule of markup (FerroUriTypeConverter and the URI literals of the compiler): a text that starts with / is relative, never a file path; a text with a scheme is absolute, where a scheme has two characters or more (C: is a drive letter, as for Uri); any other text is relative.

    The URL of an absolute reference is the canonical text of the Uri of the text (the scheme and the authority in lower case) parsed with url::Url::parse, so that for every text Uri accepts, UriRef::parse(text) is the reference of Uri::new(text, UriKind::RelativeOrAbsolute) (TryFrom<&Uri> for UriRef). A text the URL parser rejects (http://host:99999/) is its error. Unlike Uri, a scheme with nothing after it (foo:) is a URL.

    Source

    parse_absolute

    fn parse_absolute(text: &str) -> Result<url::Url, UriToUrlError>
    

    Parses an absolute URL with the rule of parse (the scheme and the authority in lower case, as the canonical text of Uri writes them): the base URI of a document (C# new Uri(text, UriKind.Absolute)). Two spellings of one document (FERRES://App/Main.xaml, ferres://app/Main.xaml) are one URL, as they are one Uri; url::Url::parse keeps the case of the host of a scheme that is not special.

    A relative reference is UriToUrlError::Relative, and a text the URL parser rejects UriToUrlError::Invalid.

    Source

    resolve

    fn resolve(self: &Self, base: &url::Url) -> Result<url::Url, url::ParseError>
    

    Resolves the reference against the absolute base (C# new Uri(Uri, Uri), Uri::combine of the port): an absolute reference is itself, and a relative one is resolved with url::Url::join.

    For the references markup writes (a relative path, a path that starts with /, dot segments, a query, a fragment) against a base of the framework (ferres://, fonts:, resm:, file://), the URL is the one of Uri::combine, converted to a URL. Url::join cannot resolve against a URL whose path is opaque (fonts:SystemFonts, resm:Fonts.Assets?assembly=App); there the reference is resolved as Uri::combine resolves it (fonts:Other). A first segment with a colon and no scheme (C:x) stays a path, as for Uri.

    Where the URL standard differs from Uri::combine, the URL follows the standard (and RFC 3986, as .NET does):

    • a reference that is only a fragment (#Name), or empty, keeps the query of the base, which Uri::combine drops;
    • a reference that starts with // names an authority (//host/path), where Uri::combine reads a path of the authority of the base;
    • empty segments (a//b) stay, where Uri::combine removes them;
    • a file: URL of a drive (file:///C:/dir/) keeps its drive for a path that starts with / and for .. above the drive, where Uri::combine goes to the root (file:///Styles/Base.xaml);
    • the special schemes are normalised as the text of every URL is (the type documentation), and the host of another scheme has the case of base (UriRef::parse and the conversions from Uri write it in lower case, as Uri does).

    Source

    as_url

    fn as_url(self: &Self) -> Option<&url::Url>
    

    The URL of an absolute reference; None for a relative one.

    Source

    is_relative

    fn is_relative(self: &Self) -> bool
    

    Whether the reference is relative (C# !IsAbsoluteUri).

    Source

    without_fragment

    fn without_fragment(self: &Self) -> UriRef
    

    The reference without its fragment (resm:A.B#Name is resm:A.B): the key of a map that compares URIs as .NET's Uri does (decision O5 of docs/idiomatic-rust-signatures.md). Uri ignores the fragment of an absolute URI only and compares a relative one by its whole text, so a key that follows Uri exactly takes this of the absolute references.

    Source

    Trait implementations

    • Send
    • Sync
    • Freeze
    • UnsafeUnpin
    • Unpin
    • UnwindSafe
    • RefUnwindSafe
    • ResourceKeyObject
    • PropertyValue
    • AnyValue
    • ClassDefaults
    • Borrow<T>
    • BorrowMut<T>
    • CloneToUninit
    • Into<U>
    • From<T>
    • TryInto<U>
    • TryFrom<U>
    • Any
    • ToOwned
    • ToString
    • ErasedDestructor
    • IntoEither
    • Clone
    • Debug
    • StructuralPartialEq
    • PartialEq
    • Eq
    • Hash
    • Display
    • FromStr
    • From<Url>
    • TryFrom<UriRef>
    • TryFrom<&UriRef>
    • TryFrom<&Uri>
    • From<&UriRef>
    • From<UriRef>

    Availability

    Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.