pub struct UriTemplate { /* private fields */ }
Expand description
The main struct that processes and builds URI Templates.
Implementations§
Source§impl UriTemplate
impl UriTemplate
Sourcepub fn new(template: &str) -> UriTemplate
pub fn new(template: &str) -> UriTemplate
Sourcepub fn set<I: IntoTemplateVar>(
&mut self,
varname: &str,
var: I,
) -> &mut UriTemplate
pub fn set<I: IntoTemplateVar>( &mut self, varname: &str, var: I, ) -> &mut UriTemplate
Sets the value of a variable in the URI Template.
§Example
ⓘ
let mut t = UriTemplate::new("{name}");
t.set("name", "John Smith");
This function returns the URITemplate
so that the set()
calls can
be chained before building.
ⓘ
let uri = UriTemplate::new("{firstname}/{lastname}")
.set("firstname", "John")
.set("lastname", "Smith")
.build();
assert_eq!(uri, "John/Smith");
Sourcepub fn delete(&mut self, varname: &str) -> bool
pub fn delete(&mut self, varname: &str) -> bool
Deletes the value of a variable in the URI Template. Returns true
if
the variable existed and false
otherwise.
Example
ⓘ
let mut t = UriTemplate::new("{animal}");
t.set("animal", "dog");
assert_eq!(t.delete("house"), false);
assert_eq!(t.delete("animal"), true);
Sourcepub fn delete_all(&mut self)
pub fn delete_all(&mut self)
Deletes the values of all variables currently set in the URITemplate
.
Auto Trait Implementations§
impl Freeze for UriTemplate
impl RefUnwindSafe for UriTemplate
impl Send for UriTemplate
impl Sync for UriTemplate
impl Unpin for UriTemplate
impl UnwindSafe for UriTemplate
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