Skip to main content

repame_shell/portal/
none.rs

1//! The backend a build without a portal installs.
2//!
3//! It is a real implementation, not a stub. Every request is refused on the
4//! spot with [`Refusal::NoPortal`], so a game that asks for an ad gets an
5//! answer on that frame instead of waiting for a host that is not there, and
6//! [`NoPortal::status`] says the same thing before anything is asked at all:
7//! `hosted: false` and every feature `Unavailable(NoPortal)`. A game can hide
8//! its rewarded button, its cloud banner and its "watch to revive" offer from
9//! that, and everything it does ask is a warning in a log rather than silence.
10
11use super::protocol::{Portal, PortalEvent, PortalRequest, PortalStatus, Refusal};
12
13/// Nothing is listening. Installed by [`PortalHost::none`], which is also the
14/// default host.
15///
16/// [`PortalHost::none`]: super::PortalHost::none
17#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
18pub struct NoPortal;
19
20impl Portal for NoPortal {
21    fn request(&mut self, _request: PortalRequest) -> Result<(), Refusal> {
22        Err(Refusal::NoPortal)
23    }
24
25    fn poll(&mut self) -> Vec<PortalEvent> {
26        Vec::new()
27    }
28
29    fn status(&self) -> PortalStatus {
30        PortalStatus::default()
31    }
32
33    fn label(&self) -> &str {
34        "no portal (desktop)"
35    }
36}