xref: /aosp_15_r20/external/crosvm/vendor/generic/broker_ipc/src/lib.rs (revision bb4ee6a4ae7042d18b07a98463b9c8b875e44b39)
1 // Copyright 2022 The ChromiumOS Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 //! Generic implementation of product specific functions that are called on child process
6 //! initialization.
7 
8 #[cfg(feature = "crash-report")]
9 pub use crash_report::CrashReportAttributes;
10 use serde::Deserialize;
11 use serde::Serialize;
12 
13 #[derive(Serialize, Deserialize)]
14 pub struct ProductAttributes {}
15 
16 impl ProductAttributes {
17     #[allow(clippy::new_without_default)]
new( #[cfg(feature = "crash-report")] _crash_attrs: CrashReportAttributes, #[cfg(feature = "process-invariants")] _process_invariants: EmulatorProcessInvariants, ) -> Self18     pub fn new(
19         #[cfg(feature = "crash-report")] _crash_attrs: CrashReportAttributes,
20         #[cfg(feature = "process-invariants")] _process_invariants: EmulatorProcessInvariants,
21     ) -> Self {
22         Self {}
23     }
24 }
25 
init_child_crash_reporting(_attrs: &ProductAttributes)26 pub fn init_child_crash_reporting(_attrs: &ProductAttributes) {
27     // Do nothing. Crash reporting is implemented by a specific product.
28 }
29 
product_child_setup(_attrs: &ProductAttributes) -> anyhow::Result<()>30 pub fn product_child_setup(_attrs: &ProductAttributes) -> anyhow::Result<()> {
31     Ok(())
32 }
33 
34 #[cfg(feature = "process-invariants")]
35 #[derive(Debug, Clone)]
36 pub struct EmulatorProcessInvariants {}
37 
38 #[cfg(feature = "process-invariants")]
init_broker_process_invariants( _data_handle: &Option<u64>, _data_size: &Option<usize>, ) -> anyhow::Result<EmulatorProcessInvariants>39 pub fn init_broker_process_invariants(
40     _data_handle: &Option<u64>,
41     _data_size: &Option<usize>,
42 ) -> anyhow::Result<EmulatorProcessInvariants> {
43     Ok(EmulatorProcessInvariants {})
44 }
45