Skip to content

Commit f550f50

Browse files
committed
Design sketch: ValidationError as trait
1 parent 2df2f1d commit f550f50

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

internal/crypto/src/ocsp/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,11 @@ pub enum OcspError {
283283
CertificateStatusUnknown,
284284
}
285285

286+
287+
impl ValidationError for OcspError {
288+
// ...
289+
}
290+
286291
const DATE_FMT: &str = "%Y-%m-%d %H:%M:%S %Z";
287292

288293
#[cfg(not(target_arch = "wasm32"))]

internal/crypto/src/raw_signature/validator.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// each license.
1313

1414
use bcder::Oid;
15+
use c2pa_status_tracker::ValidationError;
1516
use thiserror::Error;
1617

1718
use super::oids::*;
@@ -164,3 +165,7 @@ impl From<crate::webcrypto::WasmCryptoError> for RawSignatureValidationError {
164165
}
165166
}
166167
}
168+
169+
impl ValidationError for RawSignatureValidationError {
170+
// ...
171+
}

internal/status-tracker/src/error.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright 2024 Adobe. All rights reserved.
2+
// This file is licensed to you under the Apache License,
3+
// Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
4+
// or the MIT license (http://opensource.org/licenses/MIT),
5+
// at your option.
6+
7+
// Unless required by applicable law or agreed to in writing,
8+
// this software is distributed on an "AS IS" BASIS, WITHOUT
9+
// WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or
10+
// implied. See the LICENSE-MIT and LICENSE-APACHE files for the
11+
// specific language governing permissions and limitations under
12+
// each license.
13+
14+
/// A `ValidationError` describes an error that was found when validating a C2PA manifest.
15+
pub trait ValidationError {
16+
/// Returns the C2PA validation code for the error condition.
17+
///
18+
/// May return `None` if the error condition is not described in the C2PA Technical Specification.
19+
fn validation_code(&self) -> Option<Cow<'static, str>>;
20+
21+
/// Returns the JUMBF path to the location where the error condition was identified.
22+
///
23+
/// May return `None` if the error condition does not pertain to a specific box in the manifest store.
24+
fn jumbf_path(&self) -> Option<Cow<'static, str>>;
25+
}

0 commit comments

Comments
 (0)