Crates.io | sp_vcard |
lib.rs | sp_vcard |
version | 0.2.0 |
source | src |
created_at | 2023-09-30 08:54:53.424761 |
updated_at | 2023-10-02 07:22:33.885395 |
description | Simple vCard library will help you generate vCard |
homepage | |
repository | https://github.com/vyngt/vcard |
max_upload_size | |
id | 988498 |
size | 66,609 |
Simple vCard library will help you generate vCard
use std::fs;
use sp_vcard::rfc6350::parameters::BaseType;
use sp_vcard::rfc6350::values::{
Category, Email, FullName, IGender, Role, Title, Photo,
};
use sp_vcard::rfc6350::parameters::media::ImageType;
use sp_vcard::rfc6350::VCard40;
fn main() {
let mut vc = VCard40::new();
vc.full_names.add(
FullName::new()
.set_value("Hello World")
.set_language(Some("en".into()))
.add_base_type(BaseType::HOME)
.add_base_type(BaseType::WORK),
);
vc.gender.set(IGender::Male);
vc.emails.add(
Email::new()
.set_value("user@example.com")
.add_base_type(BaseType::WORK),
);
vc.categories.add(
Category::new()
.add_category("Rust")
);
vc.titles.add(
Title::new()
.set_value("Rust Developer")
.add_base_type(BaseType::HOME),
);
vc.roles.add(Role::new().set_value("Story Teller"));
let image = fs::read("./simple_image.png").unwrap();
vc.photos
.add(Photo::new().set_bytes_data(image, ImageType::PNG));
println!("{}", vc);
}