embedded_basic/
embedded_basic.rs

1//! Basic usage example demonstrating no_std compatible code
2//! This example shows how the parser can be used in no_std contexts
3
4#![allow(dead_code)]
5
6extern crate at_parser_rs;
7
8use at_parser_rs::{Args, AtError, AtResult};
9
10// Example function using Args in no_std
11fn parse_args_example() -> AtResult<'static> {
12    let args = Args { raw: "foo,bar,baz" };
13    match args.get(1) {
14        Some(val) => Ok(val),
15        None => Err(AtError::InvalidArgs),
16    }
17}
18
19// Example of error handling
20fn handle_error_example() -> &'static str {
21    match parse_args_example() {
22        Ok(val) => val,
23        Err(AtError::InvalidArgs) => "Argomento non valido",
24        Err(_) => "Errore generico",
25    }
26}
27
28// In an embedded environment, these functions can be called from main or from a task.
29
30// Mock main for compilation (in real embedded code, this would be in your firmware)
31fn main() {
32    // Example usage - in embedded this would be called from your main loop
33    let _result = handle_error_example();
34}