Struct DataSet

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

A collection of assets. Methods support serializing/deserializing, resolving property values, etc. This includes being aware of schema and prototypes.

Implementations§

Source§

impl DataSet

Source

pub fn assets(&self) -> &HashMap<AssetId, DataSetAssetInfo, RandomState>

Source

pub fn take_assets(self) -> HashMap<AssetId, DataSetAssetInfo, RandomState>

Source

pub fn restore_asset( &mut self, asset_id: AssetId, asset_name: AssetName, asset_location: AssetLocation, import_info: Option<ImportInfo>, build_info: BuildInfo, schema_set: &SchemaSet, prototype: Option<AssetId>, schema: SchemaFingerprint, properties: HashMap<String, Value, RandomState>, property_null_overrides: HashMap<String, NullOverride, RandomState>, properties_in_replace_mode: HashSet<String, RandomState>, dynamic_collection_entries: HashMap<String, OrderedSet<Uuid>, RandomState>, ) -> Result<(), DataSetErrorWithBacktrace>

Creates the asset, overwriting it if it already exists

Source

pub fn new_asset_with_id( &mut self, asset_id: AssetId, asset_name: AssetName, asset_location: AssetLocation, schema: &SchemaRecord, ) -> Result<(), DataSetErrorWithBacktrace>

Creates an asset with a particular ID with no properties set. Fails if the asset ID is already in use.

Source

pub fn new_asset( &mut self, asset_name: AssetName, asset_location: AssetLocation, schema: &SchemaRecord, ) -> AssetId

Creates a new asset with no properties set. Uses a unique UUID and should not fail

Source

pub fn new_asset_from_prototype( &mut self, asset_name: AssetName, asset_location: AssetLocation, prototype_asset_id: AssetId, ) -> Result<AssetId, DataSetErrorWithBacktrace>

Creates a new asset and sets it to use the given prototype asset ID as the new object’s prototype May fail if the prototype asset is not found

Source

pub fn copy_from_single_object( &mut self, asset_id: AssetId, single_object: &SingleObject, ) -> Result<(), DataSetErrorWithBacktrace>

Populate an empty asset with data from a SingleObject. The asset should already exist, and the schema must match.

Source

pub fn duplicate_asset( &mut self, asset_id: AssetId, schema_set: &SchemaSet, ) -> Result<AssetId, DataSetErrorWithBacktrace>

Source

pub fn delete_asset( &mut self, asset_id: AssetId, ) -> Result<(), DataSetErrorWithBacktrace>

Returns error if asset did not exist

Source

pub fn set_asset_location( &mut self, asset_id: AssetId, new_location: AssetLocation, ) -> Result<(), DataSetErrorWithBacktrace>

Returns error if asset does not exist

Source

pub fn set_import_info( &mut self, asset_id: AssetId, import_info: ImportInfo, ) -> Result<(), DataSetErrorWithBacktrace>

Returns error if asset does not exist

Source

pub fn copy_from( &mut self, other: &DataSet, asset_id: AssetId, ) -> Result<(), DataSetErrorWithBacktrace>

Returns error if other asset does not exist. This will create or overwrite the asset in this dataset and does not require that the schema be the same if the asset already existed. No validation is performed to ensure that references to other assets or the prototype exist.

Source

pub fn asset_name( &self, asset_id: AssetId, ) -> Result<&AssetName, DataSetErrorWithBacktrace>

Returns the asset name, or none if the asset was not found

Source

pub fn set_asset_name( &mut self, asset_id: AssetId, asset_name: AssetName, ) -> Result<(), DataSetErrorWithBacktrace>

Sets the asset’s name, fails if the asset does not exist

Source

pub fn asset_location(&self, asset_id: AssetId) -> Option<AssetLocation>

Returns the asset’s parent or none if the asset does not exist

Source

pub fn asset_location_chain( &self, asset_id: AssetId, ) -> Result<Vec<AssetLocation>, DataSetErrorWithBacktrace>

Returns the asset locations from the parent all the way up to the root parent. If a cycle is detected or any elements in the chain are not found, an error is returned

Source

pub fn import_info(&self, asset_id: AssetId) -> Option<&ImportInfo>

Gets the import info, returns None if the asset does not exist or there is no import info associated with the asset

Source

pub fn resolve_path_reference<P>( &self, asset_id: AssetId, path: P, ) -> Result<Option<AssetId>, DataSetErrorWithBacktrace>
where P: Into<PathReference>,

Source

pub fn resolve_canonical_path_reference( &self, asset_id: AssetId, canonical_path: &CanonicalPathReference, ) -> Result<Option<AssetId>, DataSetErrorWithBacktrace>

Source

pub fn resolve_all_hashed_path_references( &self, asset_id: AssetId, ) -> Result<HashMap<PathReferenceHash, CanonicalPathReference, RandomState>, DataSetErrorWithBacktrace>

Source

pub fn resolve_all_path_reference_overrides( &self, asset_id: AssetId, ) -> Result<HashMap<CanonicalPathReference, AssetId, RandomState>, DataSetErrorWithBacktrace>

Source

pub fn get_all_path_reference_overrides( &mut self, asset_id: AssetId, ) -> Option<&HashMap<CanonicalPathReference, AssetId, RandomState>>

Source

pub fn set_path_reference_override( &mut self, asset_id: AssetId, path: CanonicalPathReference, referenced_asset_id: AssetId, ) -> Result<(), DataSetErrorWithBacktrace>

Source

pub fn asset_prototype(&self, asset_id: AssetId) -> Option<AssetId>

Source

pub fn asset_schema(&self, asset_id: AssetId) -> Option<&SchemaRecord>

Source

pub fn hash_object( &self, asset_id: AssetId, hash_object_mode: HashObjectMode, ) -> Result<u64, DataSetErrorWithBacktrace>

Source

pub fn get_null_override( &self, schema_set: &SchemaSet, asset_id: AssetId, path: impl AsRef<str>, ) -> Result<NullOverride, DataSetErrorWithBacktrace>

Gets if the property has a null override associated with it on this object ignoring the prototype. An error will be returned if the asset doesn’t exist, the schema doesn’t exist, or if this field is not nullable

Source

pub fn set_null_override( &mut self, schema_set: &SchemaSet, asset_id: AssetId, path: impl AsRef<str>, null_override: NullOverride, ) -> Result<(), DataSetErrorWithBacktrace>

Sets or removes the null override state on this object.

Source

pub fn resolve_null_override( &self, schema_set: &SchemaSet, asset_id: AssetId, path: impl AsRef<str>, ) -> Result<NullOverride, DataSetErrorWithBacktrace>

Source

pub fn has_property_override( &self, asset_id: AssetId, path: impl AsRef<str>, ) -> Result<bool, DataSetErrorWithBacktrace>

Source

pub fn get_property_override( &self, asset_id: AssetId, path: impl AsRef<str>, ) -> Result<Option<&Value>, DataSetErrorWithBacktrace>

Source

pub fn set_property_override( &mut self, schema_set: &SchemaSet, asset_id: AssetId, path: impl AsRef<str>, value: Option<Value>, ) -> Result<Option<Value>, DataSetErrorWithBacktrace>

Source

pub fn apply_property_override_to_prototype( &mut self, schema_set: &SchemaSet, asset_id: AssetId, path: impl AsRef<str>, ) -> Result<(), DataSetErrorWithBacktrace>

Source

pub fn resolve_property<'a>( &'a self, schema_set: &'a SchemaSet, asset_id: AssetId, path: impl AsRef<str>, ) -> Result<&'a Value, DataSetErrorWithBacktrace>

Source

pub fn get_dynamic_array_entries( &self, schema_set: &SchemaSet, asset_id: AssetId, path: impl AsRef<str>, ) -> Result<Iter<'_, Uuid>, DataSetErrorWithBacktrace>

Source

pub fn get_map_entries( &self, schema_set: &SchemaSet, asset_id: AssetId, path: impl AsRef<str>, ) -> Result<Iter<'_, Uuid>, DataSetErrorWithBacktrace>

Source

pub fn add_dynamic_array_entry( &mut self, schema_set: &SchemaSet, asset_id: AssetId, path: impl AsRef<str>, ) -> Result<Uuid, DataSetErrorWithBacktrace>

Source

pub fn add_map_entry( &mut self, schema_set: &SchemaSet, asset_id: AssetId, path: impl AsRef<str>, ) -> Result<Uuid, DataSetErrorWithBacktrace>

Source

pub fn insert_dynamic_array_entry( &mut self, schema_set: &SchemaSet, asset_id: AssetId, path: impl AsRef<str>, index: usize, entry_uuid: Uuid, ) -> Result<(), DataSetErrorWithBacktrace>

Source

pub fn remove_dynamic_array_entry( &mut self, schema_set: &SchemaSet, asset_id: AssetId, path: impl AsRef<str>, element_id: Uuid, ) -> Result<bool, DataSetErrorWithBacktrace>

Source

pub fn remove_map_entry( &mut self, schema_set: &SchemaSet, asset_id: AssetId, path: impl AsRef<str>, element_id: Uuid, ) -> Result<bool, DataSetErrorWithBacktrace>

Source

pub fn resolve_dynamic_array_entries( &self, schema_set: &SchemaSet, asset_id: AssetId, path: impl AsRef<str>, ) -> Result<Box<[Uuid]>, DataSetErrorWithBacktrace>

Source

pub fn resolve_map_entries( &self, schema_set: &SchemaSet, asset_id: AssetId, path: impl AsRef<str>, ) -> Result<Box<[Uuid]>, DataSetErrorWithBacktrace>

Source

pub fn get_override_behavior( &self, schema_set: &SchemaSet, asset_id: AssetId, path: impl AsRef<str>, ) -> Result<OverrideBehavior, DataSetErrorWithBacktrace>

Source

pub fn set_override_behavior( &mut self, schema_set: &SchemaSet, asset_id: AssetId, path: impl AsRef<str>, behavior: OverrideBehavior, ) -> Result<(), DataSetErrorWithBacktrace>

Source

pub fn read_properties_bundle( &self, schema_set: &SchemaSet, asset_id: AssetId, path: impl AsRef<str>, ) -> Result<PropertiesBundle, DataSetErrorWithBacktrace>

Source

pub fn write_properties_bundle( &mut self, schema_set: &SchemaSet, asset_id: AssetId, path: impl AsRef<str>, properties_bundle: &PropertiesBundle, ) -> Result<(), DataSetErrorWithBacktrace>

Trait Implementations§

Source§

impl Clone for DataSet

Source§

fn clone(&self) -> DataSet

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 Default for DataSet

Source§

fn default() -> DataSet

Returns the “default value” for a type. 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, 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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.