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
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.
Property name (e.g., “fn”, “email”, “tel”, “adr”)
Property parameters (e.g., type, label)
Value type (e.g., “text”, “uri”)
VCardValue
Enum representing different vCard value types.
Structured value with multiple components (e.g., name parts, address parts)
VCardAddress
Structured address information.
Pre-formatted address string (if provided by server)
Extended address (e.g., apartment number)
State, province, or region
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(())
}
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