Struct Field

Source
pub struct Field { /* private fields */ }
Expand description

SIP Field with code and value.

To support passing field types that are not known at compile time, store the message code instead of a ref to a well-known spec::Field.

Implementations§

Source§

impl Field

Source

pub fn new(code: &str, value: &str) -> Self

Create a new Field with the provided code and value.

No limits are place to the length of the code or value, though in practice, the code will be 2 characters in length.

Source

pub fn value(&self) -> &str

Get the Field’s value.

Source

pub fn set_value(&mut self, value: &str)

Apply a value to this Field.

Source

pub fn code(&self) -> &str

Get the Fields’ code.

Source

pub fn to_sip(&self) -> String

Create a partial SIP string from a field.

String includes the trailing “|” delimiter.

use sip2::Field;
use sip2::spec;
let f = Field::new(spec::F_LOGIN_UID.code, "sip_username");
assert_eq!(f.to_sip(), "CNsip_username|");

Trait Implementations§

Source§

impl Debug for Field

Source§

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

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

impl PartialEq for Field

Source§

fn eq(&self, other: &Field) -> 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 StructuralPartialEq for Field

Auto Trait Implementations§

§

impl Freeze for Field

§

impl RefUnwindSafe for Field

§

impl Send for Field

§

impl Sync for Field

§

impl Unpin for Field

§

impl UnwindSafe for Field

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> 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, 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.