use std::borrow::Cow;
use serde::Serialize;
#[cfg(feature = "devtools")]
mod remote;
#[cfg(feature = "devtools")]
mod plugin;
pub struct DevtoolsPlugin(pub Devtools);
#[cfg(not(feature = "devtools"))]
impl bevy_app::Plugin for DevtoolsPlugin {
fn build(&self, _: &mut bevy_app::App) {
use bevy_log::prelude::*;
error!("you must enable wasvy's \"devtools\" feature in your Cargo.toml");
}
}
#[derive(Debug, Clone, Serialize)]
pub struct Devtools {
pub program_name: String,
pub interfaces: Vec<Cow<'static, str>>,
}
impl Default for Devtools {
fn default() -> Self {
Self {
program_name: "Bevy App powered by Wasvy".into(),
interfaces: vec![
include_str!("./../../wit/bevy-ecs.wit").into(),
include_str!("./../../wit/wasvy-ecs.wit").into(),
],
}
}
}
impl Devtools {
pub fn new(program_name: impl Into<String>) -> Self {
Self {
program_name: program_name.into(),
..Default::default()
}
}
pub fn implement(mut self, interface: impl Into<Cow<'static, str>>) -> Self {
self.interfaces.push(interface.into());
self
}
}
impl From<&'static str> for Devtools {
fn from(value: &'static str) -> Self {
Devtools {
program_name: value.into(),
..Default::default()
}
}
}
impl From<String> for Devtools {
fn from(value: String) -> Self {
Devtools {
program_name: value,
..Default::default()
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn default() {
let _ = Devtools::default();
}
}