pdk-classy 1.9.1-alpha.2

PDK Classy
Documentation
// Copyright (c) 2026, Salesforce, Inc.,
// All rights reserved.
// For full license text, see the LICENSE.txt file

//! Extractors are used to extract data from the context.

use std::convert::Infallible;

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

#[derive(Clone, Debug, Hash)]
/// The serialized configuration of the plugin
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())
    }
}