pub struct Hex<'a>(/* private fields */);
Expand description
Represents a hexadecimal color code.
Used as an input value for Color::Hex
when specifying a hexadecimal color code.
#Example
use pexels_api::{Color, Hex, SearchBuilder};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let hex_color = Hex::from_borrowed_str("#FFFFFF")?;
let uri = SearchBuilder::new().color(Color::Hex(hex_color)).build();
assert_eq!(
"https://api.pexels.com/v1/search?query=&color=%23FFFFFF",
uri.create_uri()?
);
Ok(())
}
§Errors
Returns PexelsError::HexColorCodeError
if the string is not a valid hexadecimal color code.
Implementations§
Source§impl<'a> Hex<'a>
impl<'a> Hex<'a>
Sourcepub fn from_borrowed_str(v: &'a str) -> Result<Self, PexelsError>
pub fn from_borrowed_str(v: &'a str) -> Result<Self, PexelsError>
Create a new Hex
from a string literal.
Trait Implementations§
impl<'a> StructuralPartialEq for Hex<'a>
Auto Trait Implementations§
impl<'a> Freeze for Hex<'a>
impl<'a> RefUnwindSafe for Hex<'a>
impl<'a> Send for Hex<'a>
impl<'a> Sync for Hex<'a>
impl<'a> Unpin for Hex<'a>
impl<'a> UnwindSafe for Hex<'a>
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