Skip to main content

twine_ctl/
lib.rs

1// Copyright (c) 2026 Jake Swensen
2// SPDX-License-Identifier: MPL-2.0
3//
4// This Source Code Form is subject to the terms of the Mozilla Public
5// License, v. 2.0. If a copy of the MPL was not distributed with this
6// file, You can obtain one at http://mozilla.org/MPL/2.0/.
7
8mod error;
9mod shell;
10
11pub use error::TwineCtlError;
12pub use shell::TwineCtlSerialShell;
13
14use twine_codec::{
15    Channel, ChannelMask, NetworkName, NetworkRole, OperationalDataset, PanId, Rloc16,
16};
17
18/// Control interface for Thread devices
19#[async_trait::async_trait]
20pub trait TwineCtl {
21    async fn new_random_network(&mut self) -> Result<(), TwineCtlError>;
22    async fn active_dataset(&mut self) -> Result<OperationalDataset, TwineCtlError>;
23    async fn attach_with_dataset(
24        &mut self,
25        dataset: &OperationalDataset,
26    ) -> Result<(), TwineCtlError>;
27    async fn pending_dataset(&mut self) -> Result<OperationalDataset, TwineCtlError>;
28    async fn channel(&mut self) -> Result<Channel, TwineCtlError>;
29    async fn preferred_channel_mask(&mut self) -> Result<ChannelMask, TwineCtlError>;
30    async fn supported_channel_mask(&mut self) -> Result<ChannelMask, TwineCtlError>;
31    async fn factory_reset(&mut self) -> Result<(), TwineCtlError>;
32    async fn network_name(&mut self) -> Result<NetworkName, TwineCtlError>;
33    async fn pan_id(&mut self) -> Result<PanId, TwineCtlError>;
34    async fn reset(&mut self) -> Result<(), TwineCtlError>;
35    async fn rloc16(&mut self) -> Result<Rloc16, TwineCtlError>;
36    async fn role(&mut self) -> Result<NetworkRole, TwineCtlError>;
37    async fn version(&mut self) -> Result<String, TwineCtlError>;
38    async fn uptime(&mut self) -> Result<String, TwineCtlError>;
39}