Struct contack::read_write::component::Component [−][src]
pub struct Component {
pub name: String,
pub parameters: HashMap<String, String>,
pub values: Vec<Vec<String>>,
// some fields omitted
}
read_write
only.Expand description
A Component represents one single line of VCard. It has a name, it might have a group, and some parameters.
This is how it will look when turned into a string:
GROUP.NAME;PARAM=VAL;PARAM2=VAL2:VALUE1;VALUE2
I would like to point out that Component does not stop you doing stupid things. Please do not add ‘=’ signs to values (for the same reason you don’t do that normally.)
Fields
name: String
This is the name of the VCard property.
parameters: HashMap<String, String>
These are the parameters PARAM=VAL
.
values: Vec<Vec<String>>
The values of the Component. They are an array
of arrays. Major properties are separated by
;
and minor properties by ,
.
Implementations
Creates a component from a name.
Example
Create a FN
component
use contack::read_write::Component;
assert_eq!(
Component::new("FN".to_string()).to_string(),
"FN:\r\n"
)
Sets the group to be the given value. Returns false on a group containing characters not included in [a-zA-Z0-9-], indicating the value has not been set.
Trait Implementations
Performs the conversion.
Allows a name to be translated into a component.
You should never need to call this directly and should prefer turning a whole contact into a VCard.
Example
Convert a name into a contact and print it out.
use contack::Name;
use contack::read_write::component::Component;
let name = Name {
given: vec!["John".to_string()],
family: vec!["Doe".to_string()],
..Default::default()
};
let component: Component = name.into();
// NAME:Doe;John;;;;
println!("{}", component);
Auto Trait Implementations
impl RefUnwindSafe for Component
impl UnwindSafe for Component
Blanket Implementations
Mutably borrows from an owned value. Read more
Convert self
to an expression for Diesel’s query builder. Read more
fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression where
&'a Self: AsExpression<T>,
fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression where
&'a Self: AsExpression<T>,
Convert &self
to an expression for Diesel’s query builder. Read more