Crate contack

Source
Expand description

§Contack

License: MIT License

Contack is a contact library for rust. Rather than following the RFCs exactly, it gives up some compatibility for ease of use. For example, instead of being able to express any number of job roles, Contack gives you the option of only 1, which in turn is much easier to work with.

With the read_write feature you can have native support for serialisation and deserialisation, to VCard. This is achieved as follows:

use contack::Contact;
use contack::read_write::vcard::VCard;
use std::fs::File;
use std::io::prelude::*;
use std::error::Error;

fn main() -> Result<(), Box<dyn Error>> {
    // Load a VCard file
    let mut vcard = String::new();
    File::open("my_card.vcard")?.read_to_string(&mut vcard)?;
    
    // Serialise it
    let vcard: VCard = vcard.parse()?;
    
    // Convert it to a contact
    let mut contact: Contact = vcard.try_into()?;
    
    // Make some changes
    contact.role = Some(String::from("Being a handy example."));
    
    // Convert it to a VCard representation.
    let vcard: VCard = contact.into();
    
    // Print it to the stdout
    println!("{}", vcard.to_string());

    Ok(())
}

It also supports the following external libraries:

  • Diesel diesel_support. This supports both serialisation and deserialisation.
  • Sqlx sqlx_support. This supports both serialisation and deserialisation.

Re-exports§

pub use contact_information::ContactInformation;
pub use contact_information::Type;
pub use contact_platform::ContactPlatform;
pub use date_time::DateTime;

Modules§

contact_information
Stores information regarding contact information.
contact_platform
Represents a platform of which a ContactInformation is on
date_time
Time properties in VCARD
read_writeread_write
Read Write
schemadiesel_support
sqlsql
Sql Support.

Structs§

Address
A simple structure to hold address information
Contact
A structure to store contact information.
Gender
The components correspond to the sex (biological) and gender identity.
Geo
A simple structure to hold Geo location.
Name
A name
Org
Represents an organisation.

Enums§

Sex
A sex component, representing a biological sex.
Uri
A struct which can either store byte information or a url