salamandr-plugin-sdk 0.3.0

Write Salamandr helpdesk extensions in Rust: safe typed wrappers for every host capability, the fetch_context wire contract, and an in-process mock host for testing.
Documentation
//! The wire contract of `connector_create_meeting`/
//! `connector_update_meeting`/`connector_delete_meeting` — the fixed
//! entrypoint trio a `kind = "connector"` plugin must implement (see
//! `extwasm.KindConnector`'s manifest requirement).
//!
//! These types are a field-for-field mirror of
//! internal/extwasm/adapter.go's Connector* types. Parity is pinned from
//! the Go side by internal/extwasm/sdkcontract_test.go, the same way
//! [`crate::channel`]'s types are.
//!
//! Unlike every other plugin Kind, a connector op's *only* network access
//! is [`crate::oauth_fetch`] — the host resolves and injects the vendor's
//! OAuth access token itself, so this plugin never reads or stores one.
//! `connection_user_id` on every request is the meeting's organizer,
//! echoed straight into `oauth_fetch`'s own `connection_user_id` field.

use serde::{Deserialize, Serialize};

/// CreateMeetingRequest is what the host passes to
/// `connector_create_meeting`. `start`/`end` are RFC 3339.
#[derive(Debug, Clone, Default, Deserialize)]
pub struct CreateMeetingRequest {
    pub connection_user_id: String,
    pub subject: String,
    pub start: String,
    pub end: String,
}

/// CreateMeetingResponse is `connector_create_meeting`'s
/// successful answer.
#[derive(Debug, Clone, Default, Serialize)]
pub struct CreateMeetingResponse {
    pub join_url: String,
    pub external_id: String,
}

/// CreateMeetingResult is the exact return type
/// `connector_create_meeting` must have.
pub type CreateMeetingResult = Result<CreateMeetingResponse, crate::OpError>;

/// UpdateMeetingRequest is what the host passes to
/// `connector_update_meeting`.
#[derive(Debug, Clone, Default, Deserialize)]
pub struct UpdateMeetingRequest {
    pub connection_user_id: String,
    pub external_id: String,
    pub subject: String,
    pub start: String,
    pub end: String,
}

/// UpdateMeetingResult is the exact return type
/// `connector_update_meeting` must have — a bare acknowledgement; the
/// host discards the success payload.
pub type UpdateMeetingResult = Result<(), crate::OpError>;

/// DeleteMeetingRequest is what the host passes to
/// `connector_delete_meeting`.
#[derive(Debug, Clone, Default, Deserialize)]
pub struct DeleteMeetingRequest {
    pub connection_user_id: String,
    pub external_id: String,
}

/// DeleteMeetingResult is the exact return type
/// `connector_delete_meeting` must have — a bare acknowledgement.
pub type DeleteMeetingResult = Result<(), crate::OpError>;

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn create_meeting_response_serializes_to_the_go_wire_shape() {
        let got = serde_json::to_value(CreateMeetingResponse {
            join_url: "https://vendor.example.com/j/123".into(),
            external_id: "evt_123".into(),
        })
        .expect("serialize");
        assert_eq!(got, serde_json::json!({"join_url": "https://vendor.example.com/j/123", "external_id": "evt_123"}));
    }

    #[test]
    fn create_meeting_request_decodes_the_host_input() {
        let req: CreateMeetingRequest = serde_json::from_str(
            r#"{"connection_user_id":"u1","subject":"Renewal call","start":"2026-08-12T10:00:00Z","end":"2026-08-12T10:30:00Z"}"#,
        )
        .expect("decode");
        assert_eq!(req.connection_user_id, "u1");
        assert_eq!(req.subject, "Renewal call");
    }
}