pub struct QueryParams { /* private fields */ }Expand description
Query parameters from an agent URI.
Stores key-value pairs from the query string, sorted lexicographically by key for consistent normalization.
§Reserved Parameters
version: Capability version constraint (semver)attestation: Inline PASETO attestation tokenresolver: Hint for resolution endpointttl: Cache TTL hint in seconds
Implementations§
Source§impl QueryParams
impl QueryParams
Sourcepub fn parse(input: &str) -> Result<Self, QueryError>
pub fn parse(input: &str) -> Result<Self, QueryError>
Parses query parameters from a query string (without leading ‘?’).
§Errors
Returns QueryError if any parameter is invalid.
Sourcepub fn iter(&self) -> impl Iterator<Item = (&str, &str)>
pub fn iter(&self) -> impl Iterator<Item = (&str, &str)>
Returns an iterator over the parameters.
Sourcepub fn with_param(&self, key: &str, value: &str) -> Result<Self, QueryError>
pub fn with_param(&self, key: &str, value: &str) -> Result<Self, QueryError>
Sourcepub fn without_param(&self, key: &str) -> Self
pub fn without_param(&self, key: &str) -> Self
Returns a new query without the given parameter.
§Examples
use agent_uri::QueryParams;
let query = QueryParams::parse("version=2.0&ttl=300").unwrap();
let updated = query.without_param("ttl");
assert!(updated.get("ttl").is_none());
assert_eq!(updated.get("version"), Some("2.0"));Sourcepub fn with_version(&self, v: &str) -> Result<Self, QueryError>
pub fn with_version(&self, v: &str) -> Result<Self, QueryError>
Sourcepub fn with_ttl(&self, ttl: u64) -> Result<Self, QueryError>
pub fn with_ttl(&self, ttl: u64) -> Result<Self, QueryError>
Trait Implementations§
Source§impl Clone for QueryParams
impl Clone for QueryParams
Source§fn clone(&self) -> QueryParams
fn clone(&self) -> QueryParams
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for QueryParams
impl Debug for QueryParams
Source§impl Default for QueryParams
impl Default for QueryParams
Source§fn default() -> QueryParams
fn default() -> QueryParams
Returns the “default value” for a type. Read more
Source§impl Display for QueryParams
impl Display for QueryParams
impl Eq for QueryParams
Source§impl FromStr for QueryParams
impl FromStr for QueryParams
Source§impl Ord for QueryParams
impl Ord for QueryParams
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for QueryParams
impl PartialEq for QueryParams
Source§fn eq(&self, other: &QueryParams) -> bool
fn eq(&self, other: &QueryParams) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl PartialOrd for QueryParams
impl PartialOrd for QueryParams
impl StructuralPartialEq for QueryParams
Auto Trait Implementations§
impl Freeze for QueryParams
impl RefUnwindSafe for QueryParams
impl Send for QueryParams
impl Sync for QueryParams
impl Unpin for QueryParams
impl UnsafeUnpin for QueryParams
impl UnwindSafe for QueryParams
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more