You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// Create a manifest store [`Reader`] from a stream. A Reader is used to validate C2PA data from an asset.
112
+
///
111
113
/// # Arguments
112
114
/// * `format` - The format of the stream. MIME type or extension that maps to a MIME type.
113
115
/// * `stream` - The stream to read from. Must implement the Read and Seek traits. (NOTE: Explain Send trait, required for both sync & async?).
116
+
///
114
117
/// # Returns
115
118
/// A [`Reader`] for the manifest store.
119
+
///
116
120
/// # Errors
117
121
/// Returns an [`Error`] when the manifest data cannot be read. If there's no error upon reading, you must still check validation status to ensure that the manifest data is validated. That is, even if there are no errors, the data still might not be valid.
122
+
///
118
123
/// # Example
119
124
/// This example reads from a memory buffer and prints out the JSON manifest data.
120
125
/// ```no_run
@@ -125,51 +130,163 @@ impl Reader {
125
130
/// let reader = Reader::from_stream("image/jpeg", stream).unwrap();
126
131
/// println!("{}", reader.json());
127
132
/// ```
128
-
#[async_generic()]
133
+
///
134
+
/// # Note
135
+
/// This function does not validate [CAWG identity] assertions that may be
136
+
/// contained within any C2PA Manifests. If an async call is feasible, use
137
+
/// [from_stream_with_cawg_async()]; if not, you can construct an async runtime
138
+
/// on your own and perform the CAWG validation separately as shown in the
139
+
/// following example:
140
+
///
141
+
/// ```no_run
142
+
/// use std::io::Cursor;
143
+
///
144
+
/// use c2pa::Reader;
145
+
/// let mut stream = Cursor::new(include_bytes!("../tests/fixtures/CA.jpg"));
146
+
/// let mut reader = Reader::from_stream("image/jpeg", stream).unwrap();
147
+
/// let runtime = tokio::runtime::Runtime::new().unwrap();
/// Create a manifest store [`Reader`] from a stream. A `Reader` is used to
187
+
/// validate C2PA data from an asset. This variation also validates
188
+
/// [CAWG identity] assertions within the C2PA data.
189
+
///
190
+
/// # Arguments
191
+
/// * `format` - The format of the stream. MIME type or extension that maps to a MIME type.
192
+
/// * `stream` - The stream to read from. Must implement the Read and Seek traits. (NOTE: Explain Send trait, required for both sync & async?).
193
+
///
194
+
/// # Returns
195
+
/// A [`Reader`] for the manifest store.
196
+
///
197
+
/// # Errors
198
+
/// Returns an [`Error`] when the manifest data cannot be read. If there's no error upon reading, you must still check validation status to ensure that the manifest data is validated. That is, even if there are no errors, the data still might not be valid.
199
+
///
200
+
/// # Example
201
+
/// This example reads from a memory buffer and prints out the JSON manifest data.
202
+
/// ```no_run
203
+
/// use std::io::Cursor;
204
+
///
205
+
/// use c2pa::Reader;
206
+
/// let mut stream = Cursor::new(include_bytes!("../tests/fixtures/CA.jpg"));
207
+
/// let reader = Reader::from_stream_with_cawg_async("image/jpeg", stream)
/// Create a manifest store [`Reader`] from a stream. A Reader is used to validate C2PA data from an asset.
244
+
/// # Arguments
245
+
/// * `format` - The format of the stream. MIME type or extension that maps to a MIME type.
246
+
/// * `stream` - The stream to read from. Must implement the Read and Seek traits. (NOTE: Explain Send trait, required for both sync & async?).
247
+
/// # Returns
248
+
/// A [`Reader`] for the manifest store.
249
+
/// # Errors
250
+
/// Returns an [`Error`] when the manifest data cannot be read. If there's no error upon reading, you must still check validation status to ensure that the manifest data is validated. That is, even if there are no errors, the data still might not be valid.
251
+
/// # Example
252
+
/// This example reads from a memory buffer and prints out the JSON manifest data.
253
+
/// ```no_run
254
+
/// use std::io::Cursor;
255
+
///
256
+
/// use c2pa::Reader;
257
+
/// let mut stream = Cursor::new(include_bytes!("../tests/fixtures/CA.jpg"));
258
+
/// let reader = Reader::from_stream("image/jpeg", stream).unwrap();
259
+
/// println!("{}", reader.json());
260
+
/// ```
261
+
#[cfg(not(target_arch = "wasm32"))]
262
+
pubfnfrom_stream_with_cawg_async(
263
+
format:&str,
264
+
mutstream:implRead + Seek + Send,
265
+
) -> Result<Reader>{
266
+
usecrate::identity::validator::CawgValidator;
267
+
160
268
let verify = get_settings_value::<bool>("verify.verify_after_reading")?;// defaults to true
0 commit comments