valve-keyvalue 1.0.3

A parser and serializer for the Valve KeyValue format (VMT/VDF).
Documentation
/*
   Copyright 2026 Gerg0Vagyok

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/

#[derive(Debug, PartialEq, Eq)]
pub enum Error {
	UndefinedError,
	UnexpectedEndOfFile,
	UnexpectedObjectAsKey{line: usize, col: usize},
	UnexpectedEndOfObject{line: usize, col: usize},
	MissingValue {line: usize, col: usize},
	QuoteInNonEscapeSequencedString
}

impl std::fmt::Display for Error {
	fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
		match self {
			Error::UndefinedError => write!(f, "Undefined error"),
			Error::UnexpectedEndOfFile => write!(f, "Unexpected end of file"),
			Error::UnexpectedObjectAsKey { line, col } => write!(f, "Unexpected object as key at {}:{}", line, col),
			Error::UnexpectedEndOfObject { line, col } => write!(f, "Unexpected end of object at {}:{}", line, col),
			Error::MissingValue { line, col } => write!(f, "Missing value at {}:{}", line, col),
			Error::QuoteInNonEscapeSequencedString => write!(f, "Quote in non-escape sequenced string")
		}
	}
}

impl std::error::Error for Error {}

pub type Result<T> = std::result::Result<T, Error>;