pub struct AppState {
pub config: Arc<AppConfig>,
pub imessage_repo: Arc<Mutex<MessageRepository>>,
pub private_api: Option<Arc<PrivateApiService>>,
pub webhook_service: Option<Arc<WebhookService>>,
pub findmy_friends_cache: Arc<Mutex<FindMyFriendsCache>>,
pub findmy_key: Arc<Mutex<Option<[u8; 32]>>>,
pub send_cache: Arc<Mutex<HashMap<String, Instant>>>,
pub typing_cache: Arc<Mutex<HashSet<String>>>,
pub findmy_refresh_lock: Arc<Mutex<()>>,
}Expand description
Shared application state. MessageRepository wraps rusqlite::Connection which is not Send+Sync, so we wrap it in a Mutex for thread-safe access.
Fields§
§config: Arc<AppConfig>§imessage_repo: Arc<Mutex<MessageRepository>>§private_api: Option<Arc<PrivateApiService>>§webhook_service: Option<Arc<WebhookService>>§findmy_friends_cache: Arc<Mutex<FindMyFriendsCache>>Cached FindMy friends locations (handle -> location JSON) + last refresh time
findmy_key: Arc<Mutex<Option<[u8; 32]>>>Cached FindMy device decryption key (32 bytes, from Keychain via FindMy.app)
send_cache: Arc<Mutex<HashMap<String, Instant>>>Send cache for deduplication (tempGuid -> timestamp)
typing_cache: Arc<Mutex<HashSet<String>>>Typing cache: tracks chats with active typing indicators (auto-stopped before sends)
findmy_refresh_lock: Arc<Mutex<()>>Mutex to prevent concurrent FindMy device refreshes
Implementations§
Source§impl AppState
impl AppState
pub fn new( config: AppConfig, imessage_repo: MessageRepository, private_api: Option<Arc<PrivateApiService>>, webhook_service: Option<Arc<WebhookService>>, ) -> Self
Sourcepub fn require_private_api(&self) -> Result<Arc<PrivateApiService>, AppError>
pub fn require_private_api(&self) -> Result<Arc<PrivateApiService>, AppError>
Get a reference to the Private API service, or return an error if not available/ready. Requires the Messages.app dylib to have completed IMCore initialization.
Sourcepub fn require_findmy_private_api(
&self,
) -> Result<Arc<PrivateApiService>, AppError>
pub fn require_findmy_private_api( &self, ) -> Result<Arc<PrivateApiService>, AppError>
Get a reference to the FindMy Private API service, or return an error if not enabled/ready. Requires the FindMy.app dylib to be connected and ready.
Sourcepub fn require_facetime_private_api(
&self,
) -> Result<Arc<PrivateApiService>, AppError>
pub fn require_facetime_private_api( &self, ) -> Result<Arc<PrivateApiService>, AppError>
Get a reference to the FaceTime Private API service, or return an error if not enabled/ready. Requires the FaceTime.app dylib to be connected and ready.
Sourcepub fn is_send_cached(&self, temp_guid: &str) -> bool
pub fn is_send_cached(&self, temp_guid: &str) -> bool
Check if a tempGuid is already in the send cache
Sourcepub fn cache_send(&self, temp_guid: String)
pub fn cache_send(&self, temp_guid: String)
Add a tempGuid to the send cache
Sourcepub fn uncache_send(&self, temp_guid: &str)
pub fn uncache_send(&self, temp_guid: &str)
Remove a tempGuid from the send cache
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AppState
impl !RefUnwindSafe for AppState
impl Send for AppState
impl Sync for AppState
impl Unpin for AppState
impl UnsafeUnpin for AppState
impl !UnwindSafe for AppState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more