From 181ad567199e5685578ecf7ad400257098c2e175 Mon Sep 17 00:00:00 2001 From: Fabian Freyer Date: Mon, 31 Jan 2022 06:24:07 +0100 Subject: rust: add ArrayGuard and for non-owned arrays To make use of shard functionality, we split the CoreOwnedArrayProvider into CoreArrayProvider and CoreOwnedArrayProvider. Array makes use of the CoreOwnedArrayProvider, which depends on CoreArrayProvider, while the new ArrayGuard only requires CoreArrayProvider and represents a non-owned array. --- rust/src/types.rs | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'rust/src/types.rs') diff --git a/rust/src/types.rs b/rust/src/types.rs index 221fcb17..102d064c 100644 --- a/rust/src/types.rs +++ b/rust/src/types.rs @@ -1547,16 +1547,17 @@ impl Drop for QualifiedNameAndType { } } -unsafe impl CoreOwnedArrayProvider for QualifiedNameAndType { +impl CoreArrayProvider for QualifiedNameAndType { type Raw = BNQualifiedNameAndType; type Context = (); - +} +unsafe impl CoreOwnedArrayProvider for QualifiedNameAndType { unsafe fn free(raw: *mut Self::Raw, count: usize, _context: &Self::Context) { BNFreeTypeList(raw, count); } } -unsafe impl<'a> CoreOwnedArrayWrapper<'a> for QualifiedNameAndType { +unsafe impl<'a> CoreArrayWrapper<'a> for QualifiedNameAndType { type Wrapped = &'a QualifiedNameAndType; unsafe fn wrap_raw(raw: &'a Self::Raw, _context: &'a Self::Context) -> Self::Wrapped { @@ -1595,16 +1596,18 @@ impl NameAndType { } } -unsafe impl CoreOwnedArrayProvider for NameAndType { +impl CoreArrayProvider for NameAndType { type Raw = BNNameAndType; type Context = (); +} +unsafe impl CoreOwnedArrayProvider for NameAndType { unsafe fn free(raw: *mut Self::Raw, count: usize, _context: &Self::Context) { BNFreeNameAndTypeList(raw, count); } } -unsafe impl<'a, S: 'a + BnStrCompatible> CoreOwnedArrayWrapper<'a> for NameAndType { +unsafe impl<'a, S: 'a + BnStrCompatible> CoreArrayWrapper<'a> for NameAndType { type Wrapped = &'a NameAndType; unsafe fn wrap_raw(raw: &'a Self::Raw, _context: &'a Self::Context) -> Self::Wrapped { @@ -1637,16 +1640,17 @@ impl DataVariable { } } -unsafe impl CoreOwnedArrayProvider for DataVariable { +impl CoreArrayProvider for DataVariable { type Raw = BNDataVariable; type Context = (); - +} +unsafe impl CoreOwnedArrayProvider for DataVariable { unsafe fn free(raw: *mut Self::Raw, count: usize, _context: &Self::Context) { BNFreeDataVariables(raw, count); } } -unsafe impl<'a> CoreOwnedArrayWrapper<'a> for DataVariable { +unsafe impl<'a> CoreArrayWrapper<'a> for DataVariable { type Wrapped = &'a DataVariable; unsafe fn wrap_raw(raw: &'a Self::Raw, _context: &'a Self::Context) -> Self::Wrapped { @@ -1681,18 +1685,22 @@ impl DataVariableAndName { } } -// unsafe impl CoreOwnedArrayProvider for DataVariableAndName { +// unsafe impl CoreArrayProvider for DataVariableAndName { // type Raw = BNDataVariableAndName; // type Context = (); +// } +// unsafe impl CoreOwnedArrayProvider for DataVariableAndName { // unsafe fn free(raw: *mut Self::Raw, count: usize, _context: &Self::Context) { // BNFreeDataVariablesAndName(raw, count); // } // } -// unsafe impl<'a, S: 'a + BnStrCompatible> CoreOwnedArrayWrapper<'a> for DataVariableAndName { +// unsafe impl<'a, S: 'a + BnStrCompatible> CoreArrayWrapper<'a> for DataVariableAndName { // type Wrapped = &'a DataVariableAndName; +// } +// unsafe impl<'a, S: 'a + BnStrCompatible> CoreArrayWrapper<'a> for DataVariableAndName { // unsafe fn wrap_raw(raw: &'a Self::Raw, _context: &'a Self::Context) -> Self::Wrapped { // mem::transmute(raw) // } -- cgit v1.3.1