igc_parser 0.1.7

A high-level parsing/deserializing crate for IGC flight recorder files
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use crate::error::IGCError::CommentInitError;
use crate::{Result, StrWrapper};

#[cfg(feature = "serde")] use serde::{Deserialize, Serialize};

#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
#[derive(Debug, Clone)]
pub struct Comment {
    pub content: StrWrapper,
}

impl Comment {
    pub(crate) fn parse(line: &str) -> Result<Self> {
        if line.is_empty() { return Err(CommentInitError(format!("'{line}' is too short to be a comment")))}
        let content = line[1..].to_string().into();
        Ok(Self {content})
    }
}