Struct omf::Attribute

source ·
pub struct Attribute {
    pub name: String,
    pub description: String,
    pub units: String,
    pub metadata: Map<String, Value>,
    pub location: Location,
    pub data: AttributeData,
}
Expand description

Describes data attached to an Element.

Each Element can have zero or more attributes, each attached to different parts of the element and each containing different types of data. On a set of points, one attribute might contain gold assay results and another rock-type classifications.

Fields§

§name: String

Attribute name. Should be unique within the containing element.

§description: String

Optional attribute description.

§units: String

Optional unit of the attribute data, default empty.

OMF does not currently attempt to standardize the strings you can use here, but our recommendations are:

  • Use full names, so “kilometers” rather than “km”. The abbreviations for non-metric units aren’t consistent and complex units can be confusing.

  • Use plurals, so “feet” rather than “foot”.

  • Avoid ambiguity, so “long tons” rather than just “tons”.

  • Accept American and British spellings, so “meter” and “metre” are the same.

§metadata: Map<String, Value>

Attribute metadata.

§location: Location

Selects which part of the element the attribute is attached to.

See the documentation for each Geometry variant for a list of what locations are valid.

§data: AttributeData

The attribute data.

Implementations§

source§

impl Attribute

source

pub fn from_numbers( name: impl Into<String>, location: Location, values: Array<Number>, ) -> Self

Convenience function to create a number attribute.

source

pub fn from_numbers_continuous_colormap( name: impl Into<String>, location: Location, values: Array<Number>, range: impl Into<NumberRange>, gradient: Array<Gradient>, ) -> Self

Convenience function to create a number attribute with a continuous colormap.

source

pub fn from_numbers_discrete_colormap( name: impl Into<String>, location: Location, values: Array<Number>, boundaries: Array<Boundary>, gradient: Array<Gradient>, ) -> Self

Convenience function to create a number attribute with a discrete colormap.

source

pub fn from_vectors( name: impl Into<String>, location: Location, values: Array<Vector>, ) -> Self

Convenience function to create a vector attribute.

source

pub fn from_strings( name: impl Into<String>, location: Location, values: Array<Text>, ) -> Self

Convenience function to create a string attribute.

source

pub fn from_categories( name: impl Into<String>, location: Location, values: Array<Index>, names: Array<Name>, gradient: Option<Array<Gradient>>, attributes: impl IntoIterator<Item = Attribute>, ) -> Self

Convenience function to create a category attribute.

source

pub fn from_booleans( name: impl Into<String>, location: Location, values: Array<Boolean>, ) -> Self

Convenience function to create a number attribute.

source

pub fn from_colors( name: impl Into<String>, location: Location, values: Array<Color>, ) -> Self

Convenience function to create a color attribute.

source

pub fn from_texture_map( name: impl Into<String>, image: Array<Image>, location: Location, texcoords: Array<Texcoord>, ) -> Self

Convenience function to create a mapped texture attribute.

source

pub fn from_texture_project( name: impl Into<String>, image: Array<Image>, orient: Orient2, width: f64, height: f64, ) -> Self

Convenience function to create a projected texture attribute.

source

pub fn len(&self) -> u64

Returns the length of the attribute, or zero for a projected texture.

source

pub fn is_empty(&self) -> bool

Trait Implementations§

source§

impl Clone for Attribute

source§

fn clone(&self) -> Attribute

Returns a copy 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 Attribute

source§

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

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

impl<'de> Deserialize<'de> for Attribute

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl JsonSchema for Attribute

source§

fn schema_name() -> String

The name of the generated JSON Schema. Read more
source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
source§

fn json_schema(gen: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
§

fn is_referenceable() -> bool

Whether JSON Schemas generated for this type should be re-used where possible using the $ref keyword. Read more
source§

impl PartialEq for Attribute

source§

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

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Validate for Attribute

source§

fn validate(&mut self) -> Result<Problems, Problems>

Call to validate the object, returning errors and warnings. Read more
source§

impl StructuralPartialEq for Attribute

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, dst: *mut T)

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

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

source§

fn __clone_box(&self, _: Private) -> *mut ()

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> 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, 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<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,