use std::{fmt, io};
use crate::pull_parser::{error::DataError, Result};
pub trait LoadAttribute: Sized + fmt::Debug {
type Output;
fn expecting(&self) -> String;
fn load_bool(self, _: bool) -> Result<Self::Output> {
Err(DataError::UnexpectedAttribute(self.expecting(), "boolean".into()).into())
}
fn load_i16(self, _: i16) -> Result<Self::Output> {
Err(DataError::UnexpectedAttribute(self.expecting(), "i16".into()).into())
}
fn load_i32(self, _: i32) -> Result<Self::Output> {
Err(DataError::UnexpectedAttribute(self.expecting(), "i32".into()).into())
}
fn load_i64(self, _: i64) -> Result<Self::Output> {
Err(DataError::UnexpectedAttribute(self.expecting(), "i64".into()).into())
}
fn load_f32(self, _: f32) -> Result<Self::Output> {
Err(DataError::UnexpectedAttribute(self.expecting(), "f32".into()).into())
}
fn load_f64(self, _: f64) -> Result<Self::Output> {
Err(DataError::UnexpectedAttribute(self.expecting(), "f64".into()).into())
}
fn load_seq_bool(
self,
_: impl Iterator<Item = Result<bool>>,
_len: usize,
) -> Result<Self::Output> {
Err(DataError::UnexpectedAttribute(self.expecting(), "boolean array".into()).into())
}
fn load_seq_i32(
self,
_: impl Iterator<Item = Result<i32>>,
_len: usize,
) -> Result<Self::Output> {
Err(DataError::UnexpectedAttribute(self.expecting(), "i32 array".into()).into())
}
fn load_seq_i64(
self,
_: impl Iterator<Item = Result<i64>>,
_len: usize,
) -> Result<Self::Output> {
Err(DataError::UnexpectedAttribute(self.expecting(), "i64 array".into()).into())
}
fn load_seq_f32(
self,
_: impl Iterator<Item = Result<f32>>,
_len: usize,
) -> Result<Self::Output> {
Err(DataError::UnexpectedAttribute(self.expecting(), "f32 array".into()).into())
}
fn load_seq_f64(
self,
_: impl Iterator<Item = Result<f64>>,
_len: usize,
) -> Result<Self::Output> {
Err(DataError::UnexpectedAttribute(self.expecting(), "f64 array".into()).into())
}
fn load_binary(self, _: impl io::Read, _len: u64) -> Result<Self::Output> {
Err(DataError::UnexpectedAttribute(self.expecting(), "binary data".into()).into())
}
#[inline]
fn load_binary_buffered(self, reader: impl io::BufRead, len: u64) -> Result<Self::Output> {
self.load_binary(reader, len)
}
fn load_string(self, _: impl io::Read, _len: u64) -> Result<Self::Output> {
Err(DataError::UnexpectedAttribute(self.expecting(), "string data".into()).into())
}
#[inline]
fn load_string_buffered(self, reader: impl io::BufRead, len: u64) -> Result<Self::Output> {
self.load_string(reader, len)
}
}