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
impl DataSet
pub fn assets(&self) -> &HashMap<AssetId, DataSetAssetInfo, RandomState>
pub fn take_assets(self) -> HashMap<AssetId, DataSetAssetInfo, RandomState>
Sourcepub 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>
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
Sourcepub fn new_asset_with_id(
&mut self,
asset_id: AssetId,
asset_name: AssetName,
asset_location: AssetLocation,
schema: &SchemaRecord,
) -> Result<(), DataSetErrorWithBacktrace>
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.
Sourcepub fn new_asset(
&mut self,
asset_name: AssetName,
asset_location: AssetLocation,
schema: &SchemaRecord,
) -> AssetId
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
Sourcepub fn new_asset_from_prototype(
&mut self,
asset_name: AssetName,
asset_location: AssetLocation,
prototype_asset_id: AssetId,
) -> Result<AssetId, DataSetErrorWithBacktrace>
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
Sourcepub fn copy_from_single_object(
&mut self,
asset_id: AssetId,
single_object: &SingleObject,
) -> Result<(), DataSetErrorWithBacktrace>
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.
pub fn duplicate_asset( &mut self, asset_id: AssetId, schema_set: &SchemaSet, ) -> Result<AssetId, DataSetErrorWithBacktrace>
Sourcepub fn delete_asset(
&mut self,
asset_id: AssetId,
) -> Result<(), DataSetErrorWithBacktrace>
pub fn delete_asset( &mut self, asset_id: AssetId, ) -> Result<(), DataSetErrorWithBacktrace>
Returns error if asset did not exist
Sourcepub fn set_asset_location(
&mut self,
asset_id: AssetId,
new_location: AssetLocation,
) -> Result<(), DataSetErrorWithBacktrace>
pub fn set_asset_location( &mut self, asset_id: AssetId, new_location: AssetLocation, ) -> Result<(), DataSetErrorWithBacktrace>
Returns error if asset does not exist
Sourcepub fn set_import_info(
&mut self,
asset_id: AssetId,
import_info: ImportInfo,
) -> Result<(), DataSetErrorWithBacktrace>
pub fn set_import_info( &mut self, asset_id: AssetId, import_info: ImportInfo, ) -> Result<(), DataSetErrorWithBacktrace>
Returns error if asset does not exist
Sourcepub fn copy_from(
&mut self,
other: &DataSet,
asset_id: AssetId,
) -> Result<(), DataSetErrorWithBacktrace>
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.
Sourcepub fn asset_name(
&self,
asset_id: AssetId,
) -> Result<&AssetName, DataSetErrorWithBacktrace>
pub fn asset_name( &self, asset_id: AssetId, ) -> Result<&AssetName, DataSetErrorWithBacktrace>
Returns the asset name, or none if the asset was not found
Sourcepub fn set_asset_name(
&mut self,
asset_id: AssetId,
asset_name: AssetName,
) -> Result<(), DataSetErrorWithBacktrace>
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
Sourcepub fn asset_location(&self, asset_id: AssetId) -> Option<AssetLocation>
pub fn asset_location(&self, asset_id: AssetId) -> Option<AssetLocation>
Returns the asset’s parent or none if the asset does not exist
Sourcepub fn asset_location_chain(
&self,
asset_id: AssetId,
) -> Result<Vec<AssetLocation>, DataSetErrorWithBacktrace>
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
Sourcepub fn import_info(&self, asset_id: AssetId) -> Option<&ImportInfo>
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
pub fn resolve_path_reference<P>(
&self,
asset_id: AssetId,
path: P,
) -> Result<Option<AssetId>, DataSetErrorWithBacktrace>where
P: Into<PathReference>,
pub fn resolve_canonical_path_reference( &self, asset_id: AssetId, canonical_path: &CanonicalPathReference, ) -> Result<Option<AssetId>, DataSetErrorWithBacktrace>
pub fn resolve_all_hashed_path_references( &self, asset_id: AssetId, ) -> Result<HashMap<PathReferenceHash, CanonicalPathReference, RandomState>, DataSetErrorWithBacktrace>
pub fn resolve_all_path_reference_overrides( &self, asset_id: AssetId, ) -> Result<HashMap<CanonicalPathReference, AssetId, RandomState>, DataSetErrorWithBacktrace>
pub fn get_all_path_reference_overrides( &mut self, asset_id: AssetId, ) -> Option<&HashMap<CanonicalPathReference, AssetId, RandomState>>
pub fn set_path_reference_override( &mut self, asset_id: AssetId, path: CanonicalPathReference, referenced_asset_id: AssetId, ) -> Result<(), DataSetErrorWithBacktrace>
pub fn asset_prototype(&self, asset_id: AssetId) -> Option<AssetId>
pub fn asset_schema(&self, asset_id: AssetId) -> Option<&SchemaRecord>
pub fn hash_object( &self, asset_id: AssetId, hash_object_mode: HashObjectMode, ) -> Result<u64, DataSetErrorWithBacktrace>
Sourcepub fn get_null_override(
&self,
schema_set: &SchemaSet,
asset_id: AssetId,
path: impl AsRef<str>,
) -> Result<NullOverride, DataSetErrorWithBacktrace>
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
Sourcepub fn set_null_override(
&mut self,
schema_set: &SchemaSet,
asset_id: AssetId,
path: impl AsRef<str>,
null_override: NullOverride,
) -> Result<(), DataSetErrorWithBacktrace>
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.