0.1.0-0-pre.3
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// file: crates/engines/engine-v1-platform-api/src/lib.rs
|
||||
// version: 1
|
||||
// version: 2
|
||||
|
||||
#![warn(missing_docs)]
|
||||
#![deny(unreachable_pub)]
|
||||
@@ -9,5 +9,9 @@
|
||||
|
||||
mod service;
|
||||
|
||||
/// Re-export of optional monetization capability declarations.
|
||||
pub use self::service::MonetizationCapabilities;
|
||||
/// Re-export of the minimal platform service capability enumeration.
|
||||
pub use self::service::PlatformCapability;
|
||||
/// Re-export of optional platform service availability states.
|
||||
pub use self::service::PlatformServiceAvailability;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// file: crates/engines/engine-v1-platform-api/src/service.rs
|
||||
// version: 1
|
||||
// version: 2
|
||||
|
||||
/// Platform capabilities that may have different implementations per target.
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
@@ -15,3 +15,57 @@ pub enum PlatformCapability {
|
||||
/// Online leaderboard integration.
|
||||
Leaderboard,
|
||||
}
|
||||
|
||||
/// Availability state of one optional platform service.
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
pub enum PlatformServiceAvailability {
|
||||
/// The platform implementation is present and may be used.
|
||||
Available,
|
||||
/// The platform could support the service, but this build intentionally disables it.
|
||||
Disabled,
|
||||
/// The current target or distribution does not provide this service implementation.
|
||||
Unsupported,
|
||||
}
|
||||
|
||||
/// Declarative availability of optional monetization services for one build.
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
pub struct MonetizationCapabilities {
|
||||
advertising: PlatformServiceAvailability,
|
||||
billing: PlatformServiceAvailability,
|
||||
}
|
||||
|
||||
impl MonetizationCapabilities {
|
||||
/// Creates a monetization capability declaration.
|
||||
#[must_use]
|
||||
pub const fn new(advertising: PlatformServiceAvailability, billing: PlatformServiceAvailability) -> Self {
|
||||
return Self { advertising, billing };
|
||||
}
|
||||
|
||||
/// Creates a declaration with monetization intentionally disabled.
|
||||
#[must_use]
|
||||
pub const fn disabled() -> Self {
|
||||
return Self::new(PlatformServiceAvailability::Disabled, PlatformServiceAvailability::Disabled);
|
||||
}
|
||||
|
||||
/// Returns advertising availability.
|
||||
#[must_use]
|
||||
pub const fn advertising(self) -> PlatformServiceAvailability {
|
||||
return self.advertising;
|
||||
}
|
||||
|
||||
/// Returns billing availability.
|
||||
#[must_use]
|
||||
pub const fn billing(self) -> PlatformServiceAvailability {
|
||||
return self.billing;
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod unit_tests {
|
||||
#[test]
|
||||
fn disabled_monetization_disables_both_services() {
|
||||
let capabilities = crate::MonetizationCapabilities::disabled();
|
||||
assert_eq!(capabilities.advertising(), crate::PlatformServiceAvailability::Disabled);
|
||||
assert_eq!(capabilities.billing(), crate::PlatformServiceAvailability::Disabled);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user