Skip to content

Commit cd18578

Browse files
feat(drive): document filter for state transition subscriptions part 2 (#2781)
1 parent e4cee4f commit cd18578

5 files changed

Lines changed: 423 additions & 319 deletions

File tree

packages/rs-dpp/src/validation/validation_result.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,10 @@ impl<TData: Clone, E: Debug> ValidationResult<TData, E> {
202202
self.errors.is_empty()
203203
}
204204

205+
pub fn is_err(&self) -> bool {
206+
!self.errors.is_empty()
207+
}
208+
205209
pub fn first_error(&self) -> Option<&E> {
206210
self.errors.first()
207211
}
@@ -237,6 +241,19 @@ impl<TData: Clone, E: Debug> ValidationResult<TData, E> {
237241
)))
238242
}
239243

244+
pub fn into_data_with_error(mut self) -> Result<Result<TData, E>, ProtocolError> {
245+
if let Some(error) = self.errors.pop() {
246+
Ok(Err(error))
247+
} else {
248+
self.data
249+
.map(Ok)
250+
.ok_or(ProtocolError::CorruptedCodeExecution(format!(
251+
"trying to push validation result into data (errors are {:?})",
252+
self.errors
253+
)))
254+
}
255+
}
256+
240257
pub fn into_data_and_errors(self) -> Result<(TData, Vec<E>), ProtocolError> {
241258
Ok((
242259
self.data

0 commit comments

Comments
 (0)