pdk-classy 1.3.0-alpha.0

PDK Classy
Documentation
// Copyright 2023 Salesforce, Inc. All rights reserved.
use std::convert::Infallible;

use super::{context::ConfigureContext, FromContext};

#[derive(Clone, Debug, Hash)]
pub struct Configuration(pub Vec<u8>);

impl Default for Configuration {
    fn default() -> Self {
        Self("{}".as_bytes().to_vec())
    }
}

impl FromContext<ConfigureContext> for Configuration {
    type Error = Infallible;

    fn from_context(context: &ConfigureContext) -> Result<Self, Self::Error> {
        Ok(context
            .host
            .get_plugin_configuration()
            .map(Configuration)
            .unwrap_or_default())
    }
}