### Complete Integration Example with Static IRef Macros Source: https://context7.com/timothee-haudebourg/static-iref/llms.txt This example shows how to use `uri!`, `uri_ref!`, `iri!`, and `iri_ref!` macros to define various URI and IRI constants at compile time. Ensure `iref` and `static-iref` are added as dependencies. Invalid URIs or IRIs will result in compilation errors. ```rust use iref::{Iri, IriRef, Uri, UriRef}; use static_iref::{iri, iri_ref, uri, uri_ref}; // Define API endpoints as compile-time constants const BASE_URI: &'static Uri = uri!("https://api.example.com/v1"); const USERS_PATH: &'static UriRef = uri_ref!("/users"); const PROFILE_PATH: &'static UriRef = uri_ref!("/users/profile#settings"); // Internationalized endpoints const BASE_IRI: &'static Iri = iri!("https://api.example.com/v1"); const I18N_PATH: &'static IriRef = iri_ref!("/données/utilisateur"); fn main() { // All identifiers are validated at compile time // Invalid URIs/IRIs will cause compilation errors println!("Base URI: {}", BASE_URI); println!("Users path: {}", USERS_PATH); println!("Profile path: {}", PROFILE_PATH); println!("Internationalized base: {}", BASE_IRI); println!("Internationalized path: {}", I18N_PATH); } ``` -------------------------------- ### Build Static IRI and IRI References Source: https://github.com/timothee-haudebourg/static-iref/blob/master/README.md Use the `iri!` and `iri_ref!` macros to construct static IRIs and IRI references. Ensure `iref` and `static_iref` are imported. ```rust use iref::{Iri, IriRef}; use static_iref::{iri, iri_ref}; const IRI: &'static Iri = iri!("https://www.rust-lang.org/foo/bar#frag"); const IRI_REF: &'static IriRef = iri_ref!("/foo/bar#frag"); ``` -------------------------------- ### iri! Macro Source: https://context7.com/timothee-haudebourg/static-iref/llms.txt Builds an IRI with a 'static lifetime at compile time, supporting Unicode characters. ```APIDOC ## iri! Macro ### Description Builds an IRI (Internationalized Resource Identifier) with a 'static lifetime at compile time. Supports Unicode characters. ### Parameters - **iri_string** (string literal) - Required - A valid IRI string containing optional Unicode characters. ``` -------------------------------- ### uri! Macro Source: https://context7.com/timothee-haudebourg/static-iref/llms.txt Builds a URI with a 'static lifetime at compile time, restricted to ASCII characters. ```APIDOC ## uri! Macro ### Description Builds a URI with a 'static lifetime at compile time. It accepts a single string literal representing a valid URI with ASCII characters only. If the URI is malformed, compilation will fail. ### Parameters - **uri_string** (string literal) - Required - A valid ASCII URI string. ``` -------------------------------- ### uri_ref! Macro Source: https://context7.com/timothee-haudebourg/static-iref/llms.txt Builds a URI reference with a 'static lifetime at compile time, supporting both relative and absolute paths. ```APIDOC ## uri_ref! Macro ### Description Builds a URI reference with a 'static lifetime at compile time. URI references can be relative paths or absolute URIs. ### Parameters - **uri_ref_string** (string literal) - Required - A valid ASCII URI reference string. ``` -------------------------------- ### iri_ref! Macro Source: https://context7.com/timothee-haudebourg/static-iref/llms.txt Builds an IRI reference with a 'static lifetime at compile time, supporting Unicode and relative references. ```APIDOC ## iri_ref! Macro ### Description Builds an IRI reference with a 'static lifetime at compile time, combining relative reference flexibility with Unicode support. ### Parameters - **iri_ref_string** (string literal) - Required - A valid IRI reference string. ``` -------------------------------- ### Define Static URI Reference with `uri_ref!` Source: https://context7.com/timothee-haudebourg/static-iref/llms.txt The `uri_ref!` macro creates a compile-time validated URI reference with a `'static` lifetime. It supports both relative paths and absolute URIs, suitable for path templates and relative identifiers. ```rust use iref::UriRef; use static_iref::uri_ref; // Define static URI reference constants const PATH_REF: &'static UriRef = uri_ref!("/foo/bar#frag"); const RELATIVE_PATH: &'static UriRef = uri_ref!("../resources/config.json"); const ABSOLUTE_REF: &'static UriRef = uri_ref!("https://example.com/api"); fn main() { // Use the static URI reference println!("Path reference: {}", PATH_REF); // Compare with runtime-parsed URI reference assert_eq!(PATH_REF, UriRef::new("/foo/bar#frag").unwrap()); // URI references work for both relative and absolute identifiers println!("Relative: {}", RELATIVE_PATH); println!("Absolute: {}", ABSOLUTE_REF); } ``` -------------------------------- ### Define Static URI Constant with `uri!` Source: https://context7.com/timothee-haudebourg/static-iref/llms.txt Use the `uri!` macro to define a compile-time validated URI with a `'static` lifetime. Ensure the input is an ASCII-only valid URI. This is useful for static constants and avoids runtime parsing. ```rust use iref::Uri; use static_iref::uri; // Define a static URI constant const API_ENDPOINT: &'static Uri = uri!("https://api.example.com/v1/users"); const RESOURCE_URI: &'static Uri = uri!("https://www.rust-lang.org/foo/bar#frag"); fn main() { // Use the static URI in your application println!("API endpoint: {}", API_ENDPOINT); // Access URI components println!("Scheme: {}", RESOURCE_URI.scheme().as_str()); println!("Path: {}", RESOURCE_URI.path().as_str()); // Compare with runtime-parsed URI assert_eq!( RESOURCE_URI, Uri::new("https://www.rust-lang.org/foo/bar#frag").unwrap() ); } ``` -------------------------------- ### Define Static IRI with `iri!` Source: https://context7.com/timothee-haudebourg/static-iref/llms.txt Use the `iri!` macro to construct a compile-time validated Internationalized Resource Identifier (IRI) with a `'static` lifetime. This macro supports Unicode characters, extending URIs for internationalized resource identification. ```rust use iref::Iri; use static_iref::iri; // Define static IRI constants with Unicode support const IRI: &'static Iri = iri!("https://www.rust-lang.org/foo/bar#frag"); const UNICODE_IRI: &'static Iri = iri!("https://example.com/données/résumé"); fn main() { // Use the static IRI in your application println!("IRI: {}", IRI); println!("Unicode IRI: {}", UNICODE_IRI); // Compare with runtime-parsed IRI assert_eq!( IRI, Iri::new("https://www.rust-lang.org/foo/bar#frag").unwrap() ); } ``` -------------------------------- ### Define Static IRI Reference with `iri_ref!` Source: https://context7.com/timothee-haudebourg/static-iref/llms.txt The `iri_ref!` macro generates a compile-time validated IRI reference with a `'static` lifetime. It combines relative reference flexibility with full Unicode support, ideal for internationalized path templates and resource identifiers. ```rust use iref::IriRef; use static_iref::iri_ref; // Define static IRI reference constants const IRI_REF: &'static IriRef = iri_ref!("/foo/bar#frag"); const UNICODE_REF: &'static IriRef = iri_ref!("/chemin/données#section"); fn main() { // Use the static IRI reference println!("IRI reference: {}", IRI_REF); println!("Unicode reference: {}", UNICODE_REF); // Compare with runtime-parsed IRI reference assert_eq!(IRI_REF, IriRef::new("/foo/bar#frag").unwrap()); } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.