From 260262726060a2c619fb095d5d93d1e77061ca32 Mon Sep 17 00:00:00 2001 From: imrn99 <95699343+imrn99@users.noreply.github.com> Date: Thu, 2 Jan 2025 10:22:53 +0100 Subject: [PATCH] update public api --- honeycomb-core/src/cmap/dim2/sews/mod.rs | 117 ++++------------------- 1 file changed, 19 insertions(+), 98 deletions(-) diff --git a/honeycomb-core/src/cmap/dim2/sews/mod.rs b/honeycomb-core/src/cmap/dim2/sews/mod.rs index 54f8959bd..1e4516cbb 100644 --- a/honeycomb-core/src/cmap/dim2/sews/mod.rs +++ b/honeycomb-core/src/cmap/dim2/sews/mod.rs @@ -1,7 +1,7 @@ mod one; mod two; -use stm::{StmResult, Transaction}; +use stm::Transaction; use crate::{ cmap::{CMap2, CMapResult, DartIdType}, @@ -30,22 +30,26 @@ impl CMap2 { /// /// # Errors /// - /// This method should be called in a transactional context. The `Result` is then used to - /// validate the transaction; It should not be processed manually. The policy in case of - /// failure can be defined when creating the transaction, using `Transaction::with_control`. + /// This variant will abort the sew operation and raise an error if: + /// - the transaction cannot be completed, + /// - one (or more) attribute merge fails, + /// - for `I == 2`: orientation is inconsistent. + /// + /// The returned error can be used in conjunction with transaction control to avoid any + /// modifications in case of failure at attribute level. The user can then choose, through its + /// transaction control policy, to retry or abort as he wishes (see `Transaction::with_control`). /// /// # Panics /// /// The method may panic if: /// - `I >= 3` or `I == 0` - /// - the two darts are not I-sewable, - /// - for `I == 2`: orientation is inconsistent. + /// - the two darts are not I-sewable, pub fn sew( &self, trans: &mut Transaction, ld: DartIdType, rd: DartIdType, - ) -> StmResult<()> { + ) -> CMapResult<()> { // these assertions + match on a const are optimized away assert!(I < 3); assert_ne!(I, 0); @@ -77,16 +81,20 @@ impl CMap2 { /// /// # Errors /// - /// This method should be called in a transactional context. The `Result` is then used to - /// validate the transaction; It should not be processed manually. The policy in case of - /// failure can be defined when creating the transaction, using `Transaction::with_control`. + /// This variant will abort the unsew operation and raise an error if: + /// - the transaction cannot be completed, + /// - one (or more) attribute split fails, + /// + /// The returned error can be used in conjunction with transaction control to avoid any + /// modifications in case of failure at attribute level. The user can then choose, through its + /// transaction control policy, to retry or abort as he wishes (see `Transaction::with_control`). /// /// # Panics /// /// The method may panic if: /// - `I >= 3` or `I == 0` /// - `ld` is already `I`-free, - pub fn unsew(&self, trans: &mut Transaction, ld: DartIdType) -> StmResult<()> { + pub fn unsew(&self, trans: &mut Transaction, ld: DartIdType) -> CMapResult<()> { // these assertions + match on a const are optimized away assert!(I < 3); assert_ne!(I, 0); @@ -152,91 +160,4 @@ impl CMap2 { _ => unreachable!(), } } - - /// # `I`-sew operator. - /// - /// This variant will abort the unsew operation and raise an error if attributes cannot be - /// merged correctly. - /// - /// # Arguments - /// - /// - `const I: u8` -- Sew dimension. - /// - `trans: &mut Transaction` -- Transaction associated to the operation. - /// - `ld: DartIdType` -- First dart ID. - /// - `rd: DartIdType` -- Second dart ID. - /// - /// # Errors - /// - /// This method will fail, returning an error, if: - /// - the transaction cannot be completed, - /// - one (or more) attribute merge fails, - /// - for `I == 2`: orientation is inconsistent. - /// - /// The returned error can be used in conjunction with transaction control to avoid any - /// modifications in case of failure at attribute level. The user can then choose, through its - /// transaction control policy, to retry or abort as he wishes. - /// - /// # Panics - /// - /// The method may panic if: - /// - `I >= 3` or `I == 0` - /// - the two darts are not I-sewable, - pub fn try_sew( - &self, - trans: &mut Transaction, - ld: DartIdType, - rd: DartIdType, - ) -> CMapResult<()> { - // these assertions + match on a const are optimized away - assert!(I < 3); - assert_ne!(I, 0); - match I { - 1 => self.try_one_sew(trans, ld, rd), - 2 => self.try_two_sew(trans, ld, rd), - _ => unreachable!(), - } - } - - /// # `I`-unsew operator. - /// - /// This variant will abort the unsew operation and raise an error if attributes cannot be - /// split correctly. - /// - /// # Arguments - /// - /// - `const I: u8` -- Unsew dimension. - /// - `trans: &mut Transaction` -- Transaction associated to the operation. - /// - `ld: DartIdType` -- First dart ID. - /// - /// The second dart ID is fetched using `I` and `ld`. - /// - /// # Errors - /// - /// This method will fail, returning an error, if: - /// - the transaction cannot be completed, - /// - one (or more) attribute split fails, - /// - /// The returned error can be used in conjunction with transaction control to avoid any - /// modifications in case of failure at attribute level. The user can then choose, through its - /// transaction control policy, to retry or abort as he wishes. - /// - /// # Panics - /// - /// The method may panic if: - /// - `I >= 3` or `I == 0` - /// - `ld` is already `I`-free, - pub fn try_unsew( - &self, - trans: &mut Transaction, - ld: DartIdType, - ) -> CMapResult<()> { - // these assertions + match on a const are optimized away - assert!(I < 3); - assert_ne!(I, 0); - match I { - 1 => self.try_one_unsew(trans, ld), - 2 => self.try_two_unsew(trans, ld), - _ => unreachable!(), - } - } }