File tree Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -272,6 +272,18 @@ impl Display for Error {
272
272
}
273
273
}
274
274
275
+ impl From < BackendError > for Error {
276
+ fn from ( value : BackendError ) -> Self {
277
+ Self :: Backend ( value)
278
+ }
279
+ }
280
+ #[ cfg( feature = "json" ) ]
281
+ impl From < JsonFrontendError > for Error {
282
+ fn from ( value : JsonFrontendError ) -> Self {
283
+ Self :: JsonFrontend ( value)
284
+ }
285
+ }
286
+
275
287
/// Apply a BPF filter to the calling thread.
276
288
///
277
289
/// # Arguments
@@ -325,14 +337,13 @@ pub fn apply_filter(bpf_filter: BpfProgramRef) -> Result<()> {
325
337
#[ cfg( feature = "json" ) ]
326
338
pub fn compile_from_json < R : Read > ( reader : R , arch : TargetArch ) -> Result < BpfMap > {
327
339
// Run the frontend.
328
- let seccomp_filters: HashMap < String , SeccompFilter > = JsonCompiler :: new ( arch)
329
- . compile ( reader)
330
- . map_err ( Error :: JsonFrontend ) ?;
340
+ let seccomp_filters: HashMap < String , SeccompFilter > =
341
+ JsonCompiler :: new ( arch) . compile ( reader) ?;
331
342
332
343
// Run the backend.
333
344
let mut bpf_data: BpfMap = BpfMap :: with_capacity ( seccomp_filters. len ( ) ) ;
334
345
for ( name, seccomp_filter) in seccomp_filters {
335
- bpf_data. insert ( name, seccomp_filter. try_into ( ) . map_err ( Error :: Backend ) ?) ;
346
+ bpf_data. insert ( name, seccomp_filter. try_into ( ) ?) ;
336
347
}
337
348
338
349
Ok ( bpf_data)
You can’t perform that action at this time.
0 commit comments