[−][src]Struct uritemplate::UriTemplate
The main struct that processes and builds URI Templates.
Implementations
impl UriTemplate
[src]
pub fn new(template: &str) -> UriTemplate
[src]
Creates a new URI Template from the given template string.
Example
ⓘThis example is not tested
let t = UriTemplate::new("http://example.com/{name}");
pub fn set<I: IntoTemplateVar>(
&mut self,
varname: &str,
var: I
) -> &mut UriTemplate
[src]
&mut self,
varname: &str,
var: I
) -> &mut UriTemplate
Sets the value of a variable in the URI Template.
Example
ⓘThis example is not tested
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.
ⓘThis example is not tested
let uri = UriTemplate::new("{firstname}/{lastname}") .set("firstname", "John") .set("lastname", "Smith") .build(); assert_eq!(uri, "John/Smith");
pub fn delete(&mut self, varname: &str) -> bool
[src]
Deletes the value of a variable in the URI Template. Returns true
if
the variable existed and false
otherwise.
Example
ⓘThis example is not tested
let mut t = UriTemplate::new("{animal}"); t.set("animal", "dog"); assert_eq!(t.delete("house"), false); assert_eq!(t.delete("animal"), true);
pub fn delete_all(&mut self)
[src]
Deletes the values of all variables currently set in the URITemplate
.
pub fn build(&self) -> String
[src]
Expands the template using the set variable values and returns the final String.
Example
ⓘThis example is not tested
let mut t = UriTemplate::new("{hello}"); t.set("hello", "Hello World!"); assert_eq!(t.build(), "Hello%20World%21");
Auto Trait Implementations
impl RefUnwindSafe for UriTemplate
impl Send for UriTemplate
impl Sync for UriTemplate
impl Unpin for UriTemplate
impl UnwindSafe for UriTemplate
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,