Skip to content

Commit

Permalink
feat(profile): add Profile metadata builder
Browse files Browse the repository at this point in the history
  • Loading branch information
ekkolon committed Jan 3, 2024
1 parent 7a6a942 commit 53d0982
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions src/object_type/profile.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
//! Metadata utility for the Open Graph `profile` meta tag.

use crate::{builder::MetadataBuilder, object_type::ObjectType, Result};
use crate::{
builder::MetadataBuilder, convert::ToHTML, object_type::ObjectType, Result,
};
use serde::{de::IntoDeserializer, Deserialize, Serialize};

#[derive(Serialize, Deserialize, Debug, Clone)]
Expand All @@ -13,7 +15,7 @@ pub enum Gender {
}

#[derive(Serialize, Deserialize, Default, Debug, Clone)]
pub struct Profile {
pub struct ProfileMetadataBuilder {
/// A name normally given to an individual by a parent or self-chosen.
#[serde(rename = "profile:first_name")]
pub first_name: Option<String>,
Expand All @@ -35,11 +37,22 @@ pub struct Profile {
metadata: MetadataBuilder,
}

impl Profile {
pub fn new() -> Self {
Profile {
metadata: MetadataBuilder::with_type(ObjectType::Profile),
impl ProfileMetadataBuilder {}

pub trait Profile {
fn profile(&self) -> ProfileMetadataBuilder;
}

impl Profile for MetadataBuilder {
fn profile(&self) -> ProfileMetadataBuilder {
ProfileMetadataBuilder {
metadata: MetadataBuilder {
object_type: ObjectType::Profile,
metadata: self.get().clone(),
},
..Default::default()
}
}
}

impl ToHTML for ProfileMetadataBuilder {}

0 comments on commit 53d0982

Please sign in to comment.