Struct Component

Source
pub struct Component {
    pub name: String,
    pub parameters: HashMap<String, String>,
    pub values: Vec<Vec<String>>,
    /* private fields */
}
Available on crate feature 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

Source

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"
)
Source

pub fn set_group(&mut self, group: Option<String>) -> bool

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.

Source

pub const fn get_group(&self) -> &Option<String>

Get’s this’ group

Trait Implementations§

Source§

impl Clone for Component

Source§

fn clone(&self) -> Component

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Component

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Component

Source§

fn default() -> Component

Returns the “default value” for a type. Read more
Source§

impl Display for Component

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<Address> for Component

Source§

fn from(adr: Address) -> Self

Converts to this type from the input type.
Source§

impl From<Component> for Name

Source§

fn from(comp: Component) -> Self

Converts to this type from the input type.
Source§

impl From<Component> for Org

Source§

fn from(comp: Component) -> Self

Converts to this type from the input type.
Source§

impl From<ContactInformation> for Component

Source§

fn from(ci: ContactInformation) -> Self

Converts to this type from the input type.
Source§

impl From<DateTime> for Component

Source§

fn from(dt: DateTime) -> Self

Converts to this type from the input type.
Source§

impl From<Gender> for Component

Source§

fn from(gender: Gender) -> Self

Converts to this type from the input type.
Source§

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§

fn from(name: Name) -> Self

Converts to this type from the input type.
Source§

impl From<Org> for Component

Source§

fn from(org: Org) -> Self

Converts to this type from the input type.
Source§

impl From<Uri> for Component

Source§

fn from(uri: Uri) -> Self

Converts to this type from the input type.
Source§

impl FromStr for Component

Source§

type Err = ComponentParseError

The associated error which can be returned from parsing.
Source§

fn from_str(string: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl PartialEq for Component

Source§

fn eq(&self, other: &Component) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl TryFrom<Component> for Address

Source§

type Error = FromComponentError

The type returned in the event of a conversion error.
Source§

fn try_from(comp: Component) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Component> for ContactInformation

Source§

type Error = FromComponentError

The type returned in the event of a conversion error.
Source§

fn try_from(comp: Component) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Component> for DateTime

Source§

type Error = FromComponentError

The type returned in the event of a conversion error.
Source§

fn try_from(comp: Component) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Component> for Gender

Source§

type Error = FromComponentError

The type returned in the event of a conversion error.
Source§

fn try_from(comp: Component) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Component> for Uri

Source§

type Error = FromComponentError

The type returned in the event of a conversion error.
Source§

fn try_from(comp: Component) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Eq for Component

Source§

impl StructuralPartialEq for Component

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> IntoSql for T

Source§

fn into_sql<T>(self) -> Self::Expression
where Self: Sized + AsExpression<T>,

Convert self to an expression for Diesel’s query builder. Read more
Source§

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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> ErasedDestructor for T
where T: 'static,