matc 0.1.3

Matter protocol library (controller side)
Documentation
//! Matter TLV encoders and decoders for Oven Cavity Operational State Cluster
//! Cluster ID: 0x0048
//!
//! This file is automatically generated from OperationalState_Oven.xml

#![allow(clippy::too_many_arguments)]

use anyhow;
use serde_json;


// Command encoders

// Command listing

pub fn get_command_list() -> Vec<(u32, &'static str)> {
    vec![
        (0x00, "Pause"),
        (0x01, "Stop"),
        (0x02, "Start"),
        (0x03, "Resume"),
        (0x04, "OperationalCommandResponse"),
    ]
}

pub fn get_command_name(cmd_id: u32) -> Option<&'static str> {
    match cmd_id {
        0x00 => Some("Pause"),
        0x01 => Some("Stop"),
        0x02 => Some("Start"),
        0x03 => Some("Resume"),
        0x04 => Some("OperationalCommandResponse"),
        _ => None,
    }
}

pub fn get_command_schema(cmd_id: u32) -> Option<Vec<crate::clusters::codec::CommandField>> {
    match cmd_id {
        0x00 => Some(vec![]),
        0x01 => Some(vec![]),
        0x02 => Some(vec![]),
        0x03 => Some(vec![]),
        0x04 => Some(vec![]),
        _ => None,
    }
}

pub fn encode_command_json(cmd_id: u32, _args: &serde_json::Value) -> anyhow::Result<Vec<u8>> {
    match cmd_id {
        0x00 => Ok(vec![]),
        0x01 => Ok(vec![]),
        0x02 => Ok(vec![]),
        0x03 => Ok(vec![]),
        0x04 => Ok(vec![]),
        _ => Err(anyhow::anyhow!("unknown command ID: 0x{:02X}", cmd_id)),
    }
}

// Typed facade (invokes + reads)

/// Invoke `Pause` command on cluster `Oven Cavity Operational State`.
pub async fn pause(conn: &crate::controller::Connection, endpoint: u16) -> anyhow::Result<()> {
    conn.invoke_request(endpoint, crate::clusters::defs::CLUSTER_ID_OVEN_CAVITY_OPERATIONAL_STATE, crate::clusters::defs::CLUSTER_OVEN_CAVITY_OPERATIONAL_STATE_CMD_ID_PAUSE, &[]).await?;
    Ok(())
}

/// Invoke `Stop` command on cluster `Oven Cavity Operational State`.
pub async fn stop(conn: &crate::controller::Connection, endpoint: u16) -> anyhow::Result<()> {
    conn.invoke_request(endpoint, crate::clusters::defs::CLUSTER_ID_OVEN_CAVITY_OPERATIONAL_STATE, crate::clusters::defs::CLUSTER_OVEN_CAVITY_OPERATIONAL_STATE_CMD_ID_STOP, &[]).await?;
    Ok(())
}

/// Invoke `Start` command on cluster `Oven Cavity Operational State`.
pub async fn start(conn: &crate::controller::Connection, endpoint: u16) -> anyhow::Result<()> {
    conn.invoke_request(endpoint, crate::clusters::defs::CLUSTER_ID_OVEN_CAVITY_OPERATIONAL_STATE, crate::clusters::defs::CLUSTER_OVEN_CAVITY_OPERATIONAL_STATE_CMD_ID_START, &[]).await?;
    Ok(())
}

/// Invoke `Resume` command on cluster `Oven Cavity Operational State`.
pub async fn resume(conn: &crate::controller::Connection, endpoint: u16) -> anyhow::Result<()> {
    conn.invoke_request(endpoint, crate::clusters::defs::CLUSTER_ID_OVEN_CAVITY_OPERATIONAL_STATE, crate::clusters::defs::CLUSTER_OVEN_CAVITY_OPERATIONAL_STATE_CMD_ID_RESUME, &[]).await?;
    Ok(())
}

/// Invoke `OperationalCommandResponse` command on cluster `Oven Cavity Operational State`.
pub async fn operational_command_response(conn: &crate::controller::Connection, endpoint: u16) -> anyhow::Result<()> {
    conn.invoke_request(endpoint, crate::clusters::defs::CLUSTER_ID_OVEN_CAVITY_OPERATIONAL_STATE, crate::clusters::defs::CLUSTER_OVEN_CAVITY_OPERATIONAL_STATE_CMD_ID_OPERATIONALCOMMANDRESPONSE, &[]).await?;
    Ok(())
}