MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / parse

Method parse

atomic-canonical/src/publication_review.rs:154–180  ·  view source on GitHub ↗

Admit untrusted bytes before parsing, including duplicate-key/depth checks.

(bytes: &[u8])

Source from the content-addressed store, hash-verified

152impl PublicationReview {
153 /// Admit untrusted bytes before parsing, including duplicate-key/depth checks.
154 pub fn parse(bytes: &[u8]) -> crate::Result<Self> {
155 if bytes.len() > MAX_BYTES {
156 return Err(crate::CanonicalError::Proof(
157 "publication review exceeds 1 MiB".into(),
158 ));
159 }
160 let review: Self =
161 serde_json::from_value(crate::jcs::admit_document(bytes)?).map_err(|error| {
162 crate::CanonicalError::Proof(format!("invalid publication review: {error}"))
163 })?;
164 if review.schema != SCHEMA && review.schema != LEGACY_SCHEMA {
165 return Err(crate::CanonicalError::Proof(
166 "unsupported publication review schema".into(),
167 ));
168 }
169 if review.schema == SCHEMA && review.subject.snapshot.is_none() {
170 return Err(crate::CanonicalError::Proof(
171 "v2 publication review requires retained source evidence".into(),
172 ));
173 }
174 if review.schema == LEGACY_SCHEMA && review.subject.snapshot.is_some() {
175 return Err(crate::CanonicalError::Proof(
176 "legacy publication review cannot claim v2 snapshot semantics".into(),
177 ));
178 }
179 Ok(review)
180 }
181
182 /// The exact document passed through Atomic's common signing path.
183 pub fn value(&self) -> serde_json::Value {

Callers

nothing calls this directly

Calls 4

ProofClass · 0.85
admit_documentFunction · 0.85
is_noneMethod · 0.80
lenMethod · 0.45

Tested by

no test coverage detected