pub struct Manifest {
pub id: String,
pub name: String,
pub localized_names: BTreeMap<String, String>,
pub version: String,
pub schema_version: Version,
pub interface_version: Version,
pub network_hosts: Vec<String>,
}Expand description
A parsed plugin manifest.
§Examples
use fulltime_plugin_api::Manifest;
let toml = r#"
id = "bundesliga"
name = "Bundesliga"
version = "0.1.0"
schema_version = "1.0"
interface_version = "1.0"
network_hosts = ["api.openligadb.de"]
[names]
de = "Bundesliga"
fr = "Bundesliga"
"#;
let manifest = Manifest::parse(toml).unwrap();
assert_eq!(manifest.id, "bundesliga");
assert_eq!(manifest.name, "Bundesliga");
assert_eq!(manifest.network_hosts, ["api.openligadb.de"]);
assert_eq!(manifest.localized_name("de"), "Bundesliga");
assert_eq!(manifest.localized_name("es"), "Bundesliga"); // falls back to `name`Fields§
§id: StringPlugin identifier, unique among plugins the host loads.
name: StringHuman-readable display name (e.g. "Bundesliga"), distinct from
id. A plugin manifest is the only place this is declared - hosts
must not derive a display name from id (e.g. by title-casing it).
Used as the fallback when no entry in localized_names matches the
host’s current locale.
localized_names: BTreeMap<String, String>Locale-keyed display names (e.g. "de" -> "Bundesliga"), from the
manifest’s [names] table. Prefer Manifest::localized_name over
reading this directly, since it applies the fallback to name.
version: StringPlugin’s own release version (not a contract version).
schema_version: VersionCanonical schema version this plugin’s output targets.
interface_version: VersionData-provider interface version this plugin was built against.
network_hosts: Vec<String>Network hosts this plugin requires access to.
Implementations§
Source§impl Manifest
impl Manifest
Sourcepub fn localized_name(&self, locale: &str) -> &str
pub fn localized_name(&self, locale: &str) -> &str
Returns the display name for locale, falling back to name
if the manifest declares no entry for that locale in [names].
Source§impl Manifest
impl Manifest
Sourcepub fn parse(source: &str) -> Result<Self, ManifestError>
pub fn parse(source: &str) -> Result<Self, ManifestError>
Parses and validates a manifest from its TOML source.
§Errors
Returns ManifestError::Malformed if source is not valid TOML, or
ManifestError::InvalidField if a required field is missing or a version field
is not a valid "major.minor" string. No network host in network_hosts is
contacted or otherwise validated beyond being a non-empty string.
§Examples
use fulltime_plugin_api::{Manifest, ManifestError};
let err = Manifest::parse("id = \"x\"").unwrap_err();
assert!(matches!(err, ManifestError::InvalidField { .. }));