event_source/sealed.rs
1/*
2 * Created on Fri Sep 08 2023
3 *
4 * Copyright (c) storycraft. Licensed under the MIT Licence.
5 */
6
7use core::{pin::Pin, ptr::NonNull};
8
9use sync_wrapper::SyncWrapper;
10
11pin_project_lite::pin_project! {
12 #[project(!Unpin)]
13 #[derive(Debug)]
14 pub struct Sealed<T> {
15 inner: SyncWrapper<T>,
16 }
17}
18
19impl<T> Sealed<T> {
20 pub const fn new(inner: T) -> Self {
21 Self {
22 inner: SyncWrapper::new(inner),
23 }
24 }
25
26 pub fn get_ptr_mut(self: Pin<&mut Self>) -> NonNull<T> {
27 NonNull::from(self.project().inner.get_mut())
28 }
29}