pdk-script 1.3.0-alpha.0

PDK Script
Documentation
// Copyright 2023 Salesforce, Inc. All rights reserved.
use classy::hl::{BodyState, HttpClientResponse, RequestBodyState, ResponseBodyState};

/// Binding for the top-level `payload` variable.
pub trait PayloadBinding {
    /// Returns the payload in binary format.
    fn as_bytes(&self) -> Vec<u8>;
}

impl PayloadBinding for &[u8] {
    fn as_bytes(&self) -> Vec<u8> {
        self.to_vec()
    }
}

impl PayloadBinding for RequestBodyState {
    fn as_bytes(&self) -> Vec<u8> {
        self.handler().body()
    }
}

impl PayloadBinding for ResponseBodyState {
    fn as_bytes(&self) -> Vec<u8> {
        self.handler().body()
    }
}

impl PayloadBinding for HttpClientResponse {
    fn as_bytes(&self) -> Vec<u8> {
        self.body().to_vec()
    }
}