fidl_fuchsia_thermal__common/
fidl_fuchsia_thermal__common.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
8use futures::future::{self, MaybeDone, TryFutureExt};
9use zx_status;
10
11/// A string that represents the type of client using the protocol.
12///
13/// `ClientType` is used as a parameter to [`ClientStateConnector.Connect`] to
14/// connect a [`ClientStateWatcher`] to the thermal state of the desired client
15/// type.
16///
17/// A `ClientType` value should describe the type of subsystem a client
18/// represents and must exactly (case-sensitive) match with a client entry found
19/// in the central thermal configuration. Typical examples include "audio",
20/// "wifi", etc.
21pub type ClientType = String;
22
23/// The maximum value of the normalized thermal load. This value bounds the width (and therefore
24/// also the precision) of the normalized thermal limiting range starting from 0. Trip points must
25/// be specified within this range.
26pub const MAX_THERMAL_LOAD: u32 = 100;
27
28#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
29#[repr(C)]
30pub struct ClientStateWatcherWatchResponse {
31    pub state: u64,
32}
33
34impl fidl::Persistable for ClientStateWatcherWatchResponse {}
35
36pub mod client_state_connector_ordinals {
37    pub const CONNECT: u64 = 0x65abd3ba57ddaa1d;
38}
39
40pub mod client_state_watcher_ordinals {
41    pub const WATCH: u64 = 0x44831316a9942f7e;
42}
43
44mod internal {
45    use super::*;
46
47    impl fidl::encoding::ValueTypeMarker for ClientStateWatcherWatchResponse {
48        type Borrowed<'a> = &'a Self;
49        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
50            value
51        }
52    }
53
54    unsafe impl fidl::encoding::TypeMarker for ClientStateWatcherWatchResponse {
55        type Owned = Self;
56
57        #[inline(always)]
58        fn inline_align(_context: fidl::encoding::Context) -> usize {
59            8
60        }
61
62        #[inline(always)]
63        fn inline_size(_context: fidl::encoding::Context) -> usize {
64            8
65        }
66        #[inline(always)]
67        fn encode_is_copy() -> bool {
68            true
69        }
70
71        #[inline(always)]
72        fn decode_is_copy() -> bool {
73            true
74        }
75    }
76
77    unsafe impl<D: fidl::encoding::ResourceDialect>
78        fidl::encoding::Encode<ClientStateWatcherWatchResponse, D>
79        for &ClientStateWatcherWatchResponse
80    {
81        #[inline]
82        unsafe fn encode(
83            self,
84            encoder: &mut fidl::encoding::Encoder<'_, D>,
85            offset: usize,
86            _depth: fidl::encoding::Depth,
87        ) -> fidl::Result<()> {
88            encoder.debug_check_bounds::<ClientStateWatcherWatchResponse>(offset);
89            unsafe {
90                // Copy the object into the buffer.
91                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
92                (buf_ptr as *mut ClientStateWatcherWatchResponse)
93                    .write_unaligned((self as *const ClientStateWatcherWatchResponse).read());
94                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
95                // done second because the memcpy will write garbage to these bytes.
96            }
97            Ok(())
98        }
99    }
100    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u64, D>>
101        fidl::encoding::Encode<ClientStateWatcherWatchResponse, D> for (T0,)
102    {
103        #[inline]
104        unsafe fn encode(
105            self,
106            encoder: &mut fidl::encoding::Encoder<'_, D>,
107            offset: usize,
108            depth: fidl::encoding::Depth,
109        ) -> fidl::Result<()> {
110            encoder.debug_check_bounds::<ClientStateWatcherWatchResponse>(offset);
111            // Zero out padding regions. There's no need to apply masks
112            // because the unmasked parts will be overwritten by fields.
113            // Write the fields.
114            self.0.encode(encoder, offset + 0, depth)?;
115            Ok(())
116        }
117    }
118
119    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
120        for ClientStateWatcherWatchResponse
121    {
122        #[inline(always)]
123        fn new_empty() -> Self {
124            Self { state: fidl::new_empty!(u64, D) }
125        }
126
127        #[inline]
128        unsafe fn decode(
129            &mut self,
130            decoder: &mut fidl::encoding::Decoder<'_, D>,
131            offset: usize,
132            _depth: fidl::encoding::Depth,
133        ) -> fidl::Result<()> {
134            decoder.debug_check_bounds::<Self>(offset);
135            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
136            // Verify that padding bytes are zero.
137            // Copy from the buffer into the object.
138            unsafe {
139                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
140            }
141            Ok(())
142        }
143    }
144}