pub struct URLBuilder { /* private fields */ }
Implementations§
Source§impl URLBuilder
impl URLBuilder
Sourcepub fn new() -> URLBuilder
pub fn new() -> URLBuilder
Creates a new URLBuilder instance
§Example
use url_builder::URLBuilder;
let mut ub = URLBuilder::new();
Sourcepub fn build(self) -> String
pub fn build(self) -> String
Consumes the builder and returns a String, with the formatted url.
§Example
use url_builder::URLBuilder;
let mut ub = URLBuilder::new();
ub.set_protocol("http")
.set_host("localhost")
.set_port(8000)
.add_route("query")
.add_param("first", "1")
.add_param("second", "2")
.add_param("third", "3");
let built_url = ub.build();
Sourcepub fn add_param(&mut self, param: &str, value: &str) -> &mut Self
pub fn add_param(&mut self, param: &str, value: &str) -> &mut Self
Adds a parameter to the URL.
Sourcepub fn set_protocol(&mut self, protocol: &str) -> &mut Self
pub fn set_protocol(&mut self, protocol: &str) -> &mut Self
Sets the protocol that the URL builder will use.
Sourcepub fn set_host(&mut self, host: &str) -> &mut Self
pub fn set_host(&mut self, host: &str) -> &mut Self
Sets the protocol that the URL builder will use.
Sourcepub fn set_port(&mut self, port: u16) -> &mut Self
pub fn set_port(&mut self, port: u16) -> &mut Self
Sets the port that the URL builder will use.
pub fn port(&self) -> u16
pub fn host(&self) -> &str
pub fn protocol(&self) -> &str
Trait Implementations§
Source§impl Debug for URLBuilder
impl Debug for URLBuilder
Auto Trait Implementations§
impl Freeze for URLBuilder
impl RefUnwindSafe for URLBuilder
impl Send for URLBuilder
impl Sync for URLBuilder
impl Unpin for URLBuilder
impl UnwindSafe for URLBuilder
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