Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Image::to_base64 #91

Merged
merged 3 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/generation/images.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ use serde::{Deserialize, Serialize};
pub struct Image(String);

impl Image {
pub fn from_base64(base64: &str) -> Self {
Self(base64.to_string())
pub fn from_base64(base64: impl Into<String>) -> Self {
Self(base64.into())
}

pub fn to_base64(&self) -> &str {
&self.0
}
}
8 changes: 4 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ pub trait IntoUrl: IntoUrlSealed {}

impl IntoUrl for Url {}
impl IntoUrl for String {}
impl<'a> IntoUrl for &'a str {}
impl<'a> IntoUrl for &'a String {}
impl IntoUrl for &str {}
impl IntoUrl for &String {}

pub trait IntoUrlSealed {
fn into_url(self) -> Result<Url, url::ParseError>;
Expand All @@ -42,7 +42,7 @@ impl IntoUrlSealed for Url {
}
}

impl<'a> IntoUrlSealed for &'a str {
impl IntoUrlSealed for &str {
fn into_url(self) -> Result<Url, url::ParseError> {
Url::parse(self)?.into_url()
}
Expand All @@ -52,7 +52,7 @@ impl<'a> IntoUrlSealed for &'a str {
}
}

impl<'a> IntoUrlSealed for &'a String {
impl IntoUrlSealed for &String {
fn into_url(self) -> Result<Url, url::ParseError> {
(&**self).into_url()
}
Expand Down