From 5d952b736bd2ac855d0cb517b37f19ea87fb40cb Mon Sep 17 00:00:00 2001 From: Samuel Lorch Date: Sun, 14 Jan 2024 23:11:26 +0100 Subject: [PATCH] Add Test Impl for listing Links --- src/api/network.rs | 13 +++++++++++-- src/definitions/network.rs | 5 +++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/api/network.rs b/src/api/network.rs index 4cd8932..f656bda 100644 --- a/src/api/network.rs +++ b/src/api/network.rs @@ -1,13 +1,13 @@ use super::ApiError; use crate::{ create_thing, - definitions::network::{NetworkInterface, StaticRoute}, + definitions::network::{Link, NetworkInterface, StaticRoute}, delete_thing_by_index, delete_thing_by_name, get_thing_by_index, get_thing_by_name, list_things, state::RpcState, update_thing_by_index, update_thing_by_name, }; -use jsonrpsee::RpcModule; +use jsonrpsee::{types::Params, RpcModule}; pub fn register_methods(module: &mut RpcModule) { module @@ -79,4 +79,13 @@ pub fn register_methods(module: &mut RpcModule) { delete_thing_by_name!(network.interfaces), ) .unwrap(); + module + .register_method("network.links.list", list_network_links) + .unwrap(); +} + +pub fn list_network_links(_: Params, state: &RpcState) -> Result, ApiError> { + Ok(vec![Link { + name: "test1".to_string(), + }]) } diff --git a/src/definitions/network.rs b/src/definitions/network.rs index 6d253db..ebfcac6 100644 --- a/src/definitions/network.rs +++ b/src/definitions/network.rs @@ -43,3 +43,8 @@ pub struct StaticRoute { pub metric: u64, pub comment: String, } + +#[derive(Serialize, Deserialize, Clone, Validate, Debug)] +pub struct Link { + pub name: String, +}