pub struct Component {
pub name: String,
pub parameters: HashMap<String, String>,
pub values: Vec<Vec<String>>,
/* private fields */
}
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§
Source§impl Component
impl Component
Sourcepub fn new(name: String) -> Self
pub fn new(name: String) -> Self
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"
)
Trait Implementations§
Source§impl From<ContactInformation> for Component
impl From<ContactInformation> for Component
Source§fn from(ci: ContactInformation) -> Self
fn from(ci: ContactInformation) -> Self
Source§impl From<Name> for Component
Allows a name to be translated into a component.
impl From<Name> for Component
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);
Source§impl TryFrom<Component> for ContactInformation
impl TryFrom<Component> for ContactInformation
impl Eq for Component
impl StructuralPartialEq for Component
Auto Trait Implementations§
impl Freeze for Component
impl RefUnwindSafe for Component
impl Send for Component
impl Sync for Component
impl Unpin for Component
impl UnwindSafe for Component
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoSql for T
impl<T> IntoSql for T
Source§fn into_sql<T>(self) -> Self::Expressionwhere
Self: Sized + AsExpression<T>,
fn into_sql<T>(self) -> Self::Expressionwhere
Self: Sized + AsExpression<T>,
self
to an expression for Diesel’s query builder. Read moreSource§fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expressionwhere
&'a Self: AsExpression<T>,
fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expressionwhere
&'a Self: AsExpression<T>,
&self
to an expression for Diesel’s query builder. Read more