pub struct Field {
pub var: Option<String>,
pub type_: FieldType,
pub label: Option<String>,
pub required: bool,
pub desc: Option<String>,
pub options: Vec<Option_>,
pub values: Vec<String>,
pub media: Vec<MediaElement>,
pub validate: Option<Validate>,
}Expand description
Represents a field in a data form.
Fields§
§var: Option<String>The unique identifier for this field, in the form.
type_: FieldTypeThe type of this field.
label: Option<String>The label to be possibly displayed to the user for this field.
required: boolThe form will be rejected if this field isn’t present.
desc: Option<String>The natural-language description of the field, intended for presentation in a user-agent
options: Vec<Option_>A list of allowed values.
values: Vec<String>The values provided for this field.
media: Vec<MediaElement>A list of media related to this field.
validate: Option<Validate>Validation rules for this field.
Implementations§
Source§impl Field
impl Field
Sourcepub fn new(var: &str, type_: FieldType) -> Field
pub fn new(var: &str, type_: FieldType) -> Field
Create a new Field, of the given var and type.
Sourcepub fn with_value(self, value: &str) -> Field
pub fn with_value(self, value: &str) -> Field
Set only one value in this Field.
Sourcepub fn text_single(var: &str, value: &str) -> Field
pub fn text_single(var: &str, value: &str) -> Field
Create a text-single Field with the given var and unique value.
Sourcepub fn is_form_type(&self, ty: &DataFormType) -> bool
pub fn is_form_type(&self, ty: &DataFormType) -> bool
Return true if this field is a valid form type specifier as per XEP-0068.
This function requires knowledge of the form’s type attribute as the criteria differ slightly among form types.
Trait Implementations§
Source§impl AsXml for Field
impl AsXml for Field
Source§type ItemIter<'xso_proc_as_xml_iter_lifetime> = FieldAsXmlIterator<'xso_proc_as_xml_iter_lifetime>
where
Self: 'xso_proc_as_xml_iter_lifetime
type ItemIter<'xso_proc_as_xml_iter_lifetime> = FieldAsXmlIterator<'xso_proc_as_xml_iter_lifetime> where Self: 'xso_proc_as_xml_iter_lifetime
Source§impl FromXml for Field
impl FromXml for Field
Source§fn from_events(
name: QName,
attrs: AttrMap,
ctx: &Context<'_>,
) -> Result<Self::Builder, FromEventsError>
fn from_events( name: QName, attrs: AttrMap, ctx: &Context<'_>, ) -> Result<Self::Builder, FromEventsError>
Source§fn xml_name_matcher() -> XmlNameMatcher<'static>
fn xml_name_matcher() -> XmlNameMatcher<'static>
Self may be parsed from
a given XML element. Read more