//! Provides a tiny DI like container to expose all components of the system.
//!
//! The platform is more or less a simple map which keeps all central components as
//! **Arc<T>** around. Also this keeps the central **is_running** flag which is toggled to
//! *false* once [Platform::terminate](Platform::terminate) is invoked.
//!
//! Not that in common cases [Platform::require](Platform::require) is a good way of fetching a
//! service which is known to be there. However, be aware, that once the system shutdown is
//! initiated, the internal map is cleared and empty (so that all Dropped handlers run). Therefore
//! if the code might be executed after [Platform::terminate](Platform::terminate) was called, you
//! should use [Platform::find](Platform::find) and gracefully handle the **None** case. However,
//! in most cases the lookup of services is performed during startup and therefore **require** can
//! be used.
//!
//! # Examples
//!
//! ```
//! # use std::sync::Arc;
//! # use jupiter::platform::Platform;
//! struct Service {
//! value : i32
//! }
//!
//! struct UnknownService;
//!
//! let platform = Platform::new();
//!
//! // Registers a new service...
//! platform.register::<Service>(Arc::new(Service { value: 42 }));
//!
//! // Obtains a reference to a previously registered service...
//! let service = platform.require::<Service>();
//! assert_eq!(service.value, 42);
//!
//! // Trying to obtain a service which hasn't been registered yet, returns an empty
//! // optional...
//! assert_eq!(platform.find::<UnknownService>().is_none(), true);
//!
//! // By default the platform is running...
//! assert_eq!(platform.is_running(), true);
//!
//! // Once terminated...
//! platform.terminate();
//! // All services are immediately released so that their "Dropped" handlers run...
//! assert_eq!(platform.find::<Service>().is_none(), true);
//!
//! // and the platform is no longer considered active...
//! assert_eq!(platform.is_running(), false);
//! ```
use ;
use HashMap;
use ;
use ;
/// Provides a container to keep all central services in a single place.
///
/// # Examples
///
/// Building and accessing components:
/// ```
/// # use jupiter::platform::Platform;
/// # use std::sync::Arc;
///
/// struct Service {}
///
/// #[tokio::main]
/// async fn main() {
/// let platform = Platform::new();
/// platform.register(Arc::new(Service {}));
/// assert_eq!(platform.find::<Service>().is_some(), true);
/// }
/// ```
///
/// Checking the central "is running" active..
/// ```
/// # use jupiter::platform::Platform;
/// # use std::sync::Arc;
///
/// struct Service {}
///
/// #[tokio::main]
/// async fn main() {
/// let platform = Platform::new();
/// platform.register(Arc::new(Service {}));
///
/// // By default the platform is running...
/// assert_eq!(platform.is_running(), true);
///
/// // once terminated...
/// platform.terminate();
///
/// // all services are evicted so that their Dropped handlers are executed
/// assert_eq!(platform.find::<Service>().is_some(), false);
///
/// // the platform is considered halted...
/// assert_eq!(platform.is_running(), false);
/// }
/// ```