Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minimal Object Reference Implementation #279

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: some renames
JamesMc86 committed Apr 14, 2024
commit 4cb6c13bc741a2f86c9e503658a613db929947d3
14 changes: 7 additions & 7 deletions hdf5/src/hl/references/legacy.rs
Original file line number Diff line number Diff line change
@@ -36,12 +36,12 @@ impl ObjectReference for ObjectReference1 {
pointer.cast()
}

fn create(dataspace: &Location, name: &str) -> Result<Self> {
fn create(location: &Location, name: &str) -> Result<Self> {
let mut ref_out: std::mem::MaybeUninit<hobj_ref_t> = std::mem::MaybeUninit::uninit();
let name = to_cstring(name)?;
h5call!(H5Rcreate(
ref_out.as_mut_ptr().cast(),
dataspace.id(),
location.id(),
name.as_ptr(),
Self::REF_TYPE,
-1
@@ -50,17 +50,17 @@ impl ObjectReference for ObjectReference1 {
Ok(Self { inner: reference })
}

fn get_object_type(&self, dataset: &Location) -> Result<hdf5_sys::h5o::H5O_type_t> {
fn get_object_type(&self, location: &Location) -> Result<hdf5_sys::h5o::H5O_type_t> {
let mut objtype = std::mem::MaybeUninit::<H5O_type_t>::uninit();
h5call!(H5Rget_obj_type2(dataset.id(), H5R_OBJECT1, self.ptr(), objtype.as_mut_ptr()))?;
h5call!(H5Rget_obj_type2(location.id(), H5R_OBJECT1, self.ptr(), objtype.as_mut_ptr()))?;
let objtype = unsafe { objtype.assume_init() };
Ok(objtype)
}

fn dereference(&self, dataset: &Location) -> Result<ReferencedObject> {
let object_type = self.get_object_type(dataset)?;
fn dereference(&self, location: &Location) -> Result<ReferencedObject> {
let object_type = self.get_object_type(location)?;
let object_id =
h5call!(H5Rdereference(dataset.id(), H5P_DEFAULT, H5R_OBJECT1, self.ptr()))?;
h5call!(H5Rdereference(location.id(), H5P_DEFAULT, H5R_OBJECT1, self.ptr()))?;
ReferencedObject::from_type_and_id(object_type, object_id)
}
}
2 changes: 1 addition & 1 deletion hdf5/src/hl/references/mod.rs
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@ pub trait ObjectReference: Sized + H5Type {
/// Create a new reference in the same structure as the location provided.
fn create(location: &Location, name: &str) -> Result<Self>;

/// Dereference the object reference.
/// Dereference the object reference in the space provided.
fn dereference(&self, location: &Location) -> Result<ReferencedObject>;
}
/// The result of dereferencing an [object reference](ObjectReference).