Skip to main content

crux_platform/
lib.rs

1#![allow(clippy::unsafe_derive_deserialize)]
2//! # Deprecated
3//!
4//! This crate is deprecated and will no longer be maintained.
5//!
6//! The `Platform` capability was originally provided as a convenience for querying the current
7//! platform from the shell. Create a custom capability in your own project instead —
8//! see the [README](https://crates.io/crates/crux_platform) for a drop-in migration snippet.
9
10pub mod command;
11pub mod protocol;
12
13use std::marker::PhantomData;
14
15use crux_core::{Command, Request, command::RequestBuilder};
16
17pub use protocol::*;
18
19#[deprecated(
20    since = "0.10.0",
21    note = "The `crux_platform` crate is deprecated. Copy the types into your own project instead. See the README for migration guidance: https://crates.io/crates/crux_platform"
22)]
23pub struct Platform<Effect, Event> {
24    effect: PhantomData<Effect>,
25    event: PhantomData<Event>,
26}
27
28#[allow(deprecated)]
29impl<Effect, Event> Platform<Effect, Event>
30where
31    Effect: From<Request<PlatformRequest>> + Send + 'static,
32    Event: Send + 'static,
33{
34    /// Get the platform of the shell
35    #[must_use]
36    pub fn get() -> RequestBuilder<Effect, Event, impl Future<Output = PlatformResponse>> {
37        Command::request_from_shell(PlatformRequest)
38    }
39}