Skip to main content

DataEntity

Struct DataEntity 

Source
pub struct DataEntity {
    pub id: String,
    pub type_: DataType,
    pub dynamic_entity: Option<HashMap<String, EntityValue>>,
}
Expand description

Represents a data entity with an identifier, type, and dynamic properties.

DataEntity is designed to encapsulate an entity with a unique identifier (id), a specific type (type_), and a set of dynamic properties (dynamic_entity). This struct is used to handle Data entities that have a predefined structure along with additional properties that may vary.

Fields§

§id: String

URI to data

§type_: DataType

Defined type, if file MUST be type ‘File’

§dynamic_entity: Option<HashMap<String, EntityValue>>

Additional metadata

Implementations§

Source§

impl DataEntity

Source

pub fn get_property_value( &self, property: &str, ) -> Option<(String, EntityValue)>

Gets ID and value of specific target property

Source

pub fn find_value_details( &self, target_value: &EntityValue, ) -> Option<(String, String)>

Searches through every value in the struct to find the key for a matching input value.

§Arguments
  • target_value - The value to search for, as an EntityValue.
§Returns

An Option<String> containing the key if the value exists, or None otherwise.

Source

pub fn get_linked_ids(&self) -> Vec<Id>

Trait Implementations§

Source§

impl Clone for DataEntity

Source§

fn clone(&self) -> DataEntity

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 CustomSerialize for DataEntity

Provides custom serialization for DataEntity.

Implements custom serialization logic as defined in the CustomSerialize trait. This allows DataEntity to be serialized with custom rules, especially for the dynamic properties in the dynamic_entity field.

Source§

fn dynamic_entity(&self) -> Option<&HashMap<String, EntityValue>>

Source§

fn id(&self) -> &String

Source§

fn type_(&self) -> &DataType

Source§

fn custom_serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Source§

impl Debug for DataEntity

Source§

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

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

impl<'de> Deserialize<'de> for DataEntity

Custom deserialization implementation for DataEntity.

This method provides a tailored approach to convert serialized data (like JSON) into a DataEntity instance. It employs a DataEntityVisitor for map-based deserialization.

The method expects the serialized data to be in a map format (key-value pairs), which is typical for formats like JSON. It specifically looks for @id and @type keys to fill the corresponding fields of DataEntity. All other keys are treated as dynamic properties and are stored in a HashMap.

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 Display for DataEntity

Custom display formatting for DataEntity

Source§

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

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

impl DynamicEntityManipulation for DataEntity

Provides functionality for manipulating dynamic properties of a DataEntity.

This trait implementation allows for adding, modifying, and removing dynamic properties stored in the dynamic_entity field of DataEntity.

Source§

fn dynamic_entity(&mut self) -> &mut Option<HashMap<String, EntityValue>>

Gets a mutable reference to the dynamic entity’s underlying HashMap.
Source§

fn dynamic_entity_immut(&self) -> &Option<HashMap<String, EntityValue>>

Gets an immutable reference to the dynamic entity’s underlying HashMap.
Source§

fn add_dynamic_fields(&mut self, values: HashMap<String, EntityValue>)

Adds dynamic fields to the entity Read more
Source§

fn add_string_value(&mut self, key: String, value: String)

Adds a string value to the dynamic entity. Read more
Source§

fn add_id_value(&mut self, key: String, value: Id)

Adds an identifier value to the dynamic entity. Read more
Source§

fn remove_field(&mut self, key: &str)

Removes a field from the dynamic entity. Read more
Source§

fn search_value(&self, search_value: &EntityValue) -> bool

Searches for a specific value within the dynamic entity. Read more
Source§

fn search_properties_for_value( &self, search_property: &str, ) -> Option<EntityValue>

Finds keys within the RO-Crate matching a specified key or retrieves all keys. Read more
Source§

fn get_all_keys(&self) -> Vec<String>

Get all keys containing within a dynamic_entity
Source§

fn remove_matching_value(&mut self, target_id: &str)

Method to remove a matching value from the dynamic_entity field. Read more
Source§

fn update_matching_id(&mut self, id_old: &str, id_new: &str) -> Option<bool>

Updates all occurrences of a specific ID with a new ID within the dynamic entity fields. Read more
Source§

impl Serialize for DataEntity

Custom serde serialization implementation for DataEntity.

Delegates the serialization process to the custom_serialize method provided by the CustomSerialize trait implementation.

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

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. 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> ToStringFallible for T
where T: Display,

Source§

fn try_to_string(&self) -> Result<String, TryReserveError>

ToString::to_string, but without panic on OOM.

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> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,