MCPcopy Create free account
hub / github.com/aws/clock-bound / default

Method default

clock-bound/src/daemon/io/vmclock.rs:218–243  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

216 }
217}
218
219impl std::fmt::Debug for VMClock {
220 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
221 let state = self.shared_state.lock().map(|s| *s).ok();
222 f.debug_struct("VMClock")
223 .field("path", &self.path)
224 .field("shared_state", &state)
225 .field("interval", &self.interval)
226 .finish_non_exhaustive()
227 }
228}
229
230/// This is a wrapper for the [`VMClockShmReader`] struct used to bypass its !Send rules.
231///
232/// [`VMClockShmReader`] has explicit rules against the implementation of `Send`. These were
233/// implemented, in part, to protect those using Clockbound as a library, where the underlying
234/// pointers in `VMClockShmReader` could result in unexpected behavior due to their unsafe nature.
235/// Unlike the `VMClockShmReader` `Reader` is not apart of the external facing library and in the
236/// context of the ClockBound daemon its use is constrained such that it can be utilized safely.
237/// Within the Clockbound context that means the Reader cannot be copied, the underlying pointers
238/// can not be accessed directly and only one task has access to the struct.
239struct Reader(VMClockShmReader);
240
241impl Reader {
242 fn new(path: &str) -> Result<Self, ShmError> {
243 Ok(Reader(VMClockShmReader::new(path)?))
244 }
245
246 fn snapshot(&mut self) -> Result<&VMClockShmBody, ShmError> {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected