Skip to main content

at_parser_rs/
context.rs

1/***************************************************************************
2 *
3 * AT Command Parser
4 * Copyright (C) 2026 Antonio Salsi <passy.linux@zresa.it>
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 *
18 ***************************************************************************/
19 
20use crate::{Args, AtError, AtResult};
21
22/// Trait that defines the context for AT command execution.
23/// Implementations of this trait handle the actual logic for each AT command form.
24pub trait AtContext {
25
26    /// Execute command (AT+CMD)
27    /// This is called when a command is invoked without any suffix.
28    fn exec(&self) -> AtResult<'static> {
29        Err(AtError::NotSupported)
30    }
31
32    /// Query command (AT+CMD?)
33    /// This is called to retrieve the current value/state of a command.
34    fn query(&mut self) -> AtResult<'static> {
35        Err(AtError::NotSupported)
36    }
37    
38    /// Test command (AT+CMD=?)
39    /// This is called to check if a command is supported or to get valid parameter ranges.
40    fn test(&mut self) -> AtResult<'static> {
41        Err(AtError::NotSupported)
42    }
43
44    /// Set command (AT+CMD=args)
45    /// This is called to set parameters for a command.
46    fn set(&mut self, _args: Args) -> AtResult<'static> {
47        Err(AtError::NotSupported)
48    }
49
50}