pub struct PanelContent<'session> { /* private fields */ }Expand description
Panel content operations of a session (session.panel_content()).
A served GUI panel shows a page of a content bundle this session publishes. Every user’s
mixer loads the page in its own browser and fetches the files over the session; the page
sends with qaros.panel.send(msg) and receives with qaros.panel.onMessage(cb). Publishing
copies every byte, so an edit needs another publication, which reloads every panel showing
the bundle. Only the publisher may put its bundle on a panel, receives the panels’ messages
and posts to them. Limits: 16 MiB per file, 64 MiB and 1024 files per bundle, 64 KiB per
message.
Implementations§
Source§impl<'session> PanelContent<'session>
impl<'session> PanelContent<'session>
Sourcepub fn publish_files(
&self,
name: &str,
files: &[PanelContentFile],
) -> Result<PanelContentBundleId>
pub fn publish_files( &self, name: &str, files: &[PanelContentFile], ) -> Result<PanelContentBundleId>
Publishes files as bundle name (qar_panel_content_publish_files), replacing an
earlier publication of that name. Nothing is published when it fails:
PANEL_CONTENT_BUNDLE_REFUSED, PANEL_CONTENT_PATH_REFUSED,
PANEL_CONTENT_MIME_REFUSED or PANEL_CONTENT_SIZE_REFUSED.
Sourcepub fn publish_directory(
&self,
name: &str,
root: &Path,
) -> Result<PanelContentBundleId>
pub fn publish_directory( &self, name: &str, root: &Path, ) -> Result<PanelContentBundleId>
Publishes every regular file under root as bundle name
(qar_panel_content_publish_directory). A link inside the folder is refused, as is every
file PanelContent::publish_files refuses; a missing folder is
PANEL_CONTENT_NOT_FOUND.
Sourcepub fn remove(&self, bundle: &PanelContentBundleId) -> Result<()>
pub fn remove(&self, bundle: &PanelContentBundleId) -> Result<()>
Stops serving a bundle this session published (qar_panel_content_remove). Panels
showing it stay and show nothing.
Sourcepub fn post_message(
&self,
bundle: &PanelContentBundleId,
json: &str,
panel: Option<GuiPanelId>,
user: Option<PeerId>,
) -> Result<()>
pub fn post_message( &self, bundle: &PanelContentBundleId, json: &str, panel: Option<GuiPanelId>, user: Option<PeerId>, ) -> Result<()>
Posts one JSON value to the panels showing a bundle this session published
(qar_panel_content_post_message): to one panel or all (None), for one user or all.
Sourcepub fn subscribe_messages(
&self,
bundle: &PanelContentBundleId,
callback: impl Fn(PanelContentMessage) + Send + Sync + 'static,
) -> Result<Subscription>
pub fn subscribe_messages( &self, bundle: &PanelContentBundleId, callback: impl Fn(PanelContentMessage) + Send + Sync + 'static, ) -> Result<Subscription>
Calls callback with every message a panel showing the bundle sends
(qar_panel_content_subscribe_messages). Runs on library threads; validate each message
before acting on it and authorise per PanelContentMessage::user.