Skip to main content

Overview

The VCard struct represents contact information in jCard format (RFC 7095), which is the JSON representation of vCard (RFC 6350). VCards are used in RDAP Entity objects to store contact details.

VCard

Represents a vCard with multiple properties.

Methods

from_array
fn(&[Value]) -> Option<Self>
Parse a VCard from jCard array format
name
fn(&self) -> Option<&str>
Get the formatted name (FN property)
email
fn(&self) -> Option<&str>
Get the email address
tel
fn(&self) -> Option<&str>
Get the telephone number
org
fn(&self) -> Option<&str>
Get the organization name
address
fn(&self) -> Option<VCardAddress>
Get the address components
properties
fn(&self) -> &[VCardProperty]
Get all vCard properties

Example: Accessing Contact Information

use rdap::{RdapClient, RdapRequest, QueryType, RdapObject};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = RdapClient::new()?;
    let request = RdapRequest::new(QueryType::Domain, "example.com");
    let result = client.query(&request).await?;
    
    if let RdapObject::Domain(domain) = result {
        for entity in &domain.entities {
            if let Some(vcard) = &entity.vcard {
                // Access common fields
                if let Some(name) = vcard.name() {
                    println!("Name: {}", name);
                }
                if let Some(email) = vcard.email() {
                    println!("Email: {}", email);
                }
                if let Some(tel) = vcard.tel() {
                    println!("Phone: {}", tel);
                }
                if let Some(org) = vcard.org() {
                    println!("Organization: {}", org);
                }
                
                // Access address
                if let Some(addr) = vcard.address() {
                    if let Some(label) = &addr.label {
                        println!("Address: {}", label);
                    } else {
                        println!("Street: {}", addr.street);
                        println!("City: {}", addr.locality);
                        println!("State: {}", addr.region);
                        println!("Postal: {}", addr.postal_code);
                        println!("Country: {}", addr.country);
                    }
                }
            }
        }
    }
    
    Ok(())
}

VCardProperty

Individual vCard property with parameters and value.
name
String
Property name (e.g., “fn”, “email”, “tel”, “adr”)
parameters
Map<String, Value>
Property parameters (e.g., type, label)
value_type
String
Value type (e.g., “text”, “uri”)
value
VCardValue
The property value

VCardValue

Enum representing different vCard value types.
Text
String
Simple text value
Structured
Vec<String>
Structured value with multiple components (e.g., name parts, address parts)
Array
Vec<String>
Array of values

VCardAddress

Structured address information.
label
Option<String>
Pre-formatted address string (if provided by server)
po_box
String
Post office box
extended
String
Extended address (e.g., apartment number)
street
String
Street address
locality
String
City or locality
region
String
State, province, or region
postal_code
String
Postal code or ZIP code
country
String
Country name

Example: Filtering by Role

use rdap::{RdapClient, RdapRequest, QueryType, RdapObject};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = RdapClient::new()?;
    let request = RdapRequest::new(QueryType::Domain, "example.com");
    let result = client.query(&request).await?;
    
    if let RdapObject::Domain(domain) = result {
        // Find technical contact
        for entity in &domain.entities {
            if entity.roles.contains(&"technical".to_string()) {
                if let Some(vcard) = &entity.vcard {
                    println!("Technical Contact:");
                    if let Some(name) = vcard.name() {
                        println!("  Name: {}", name);
                    }
                    if let Some(email) = vcard.email() {
                        println!("  Email: {}", email);
                    }
                }
            }
        }
        
        // Find administrative contact
        for entity in &domain.entities {
            if entity.roles.contains(&"administrative".to_string()) {
                if let Some(vcard) = &entity.vcard {
                    println!("Administrative Contact:");
                    if let Some(name) = vcard.name() {
                        println!("  Name: {}", name);
                    }
                    if let Some(email) = vcard.email() {
                        println!("  Email: {}", email);
                    }
                }
            }
        }
    }
    
    Ok(())
}

jCard Format

The jCard format (RFC 7095) represents vCard data as JSON arrays. Each property is represented as:
["property-name", {parameters}, "value-type", "value"]
Example jCard:
["vcard",
  [
    ["version", {}, "text", "4.0"],
    ["fn", {}, "text", "John Doe"],
    ["email", {}, "text", "[email protected]"],
    ["tel", {"type": "work"}, "text", "+1-555-0100"],
    ["adr", {},
      "text",
      ["", "", "123 Main St", "Anytown", "CA", "12345", "USA"]
    ]
  ]
]
Many RDAP servers redact contact information for privacy. You may see “REDACTED FOR PRIVACY” in place of actual values.

Common vCard Properties

  • fn - Formatted name
  • email - Email address
  • tel - Telephone number
  • org - Organization
  • adr - Postal address
  • title - Job title
  • role - Role or occupation
  • url - Website URL
  • version - vCard version (usually “4.0”)

See Also

Build docs developers (and LLMs) love