use crate::error::SteamError;
#[derive(Debug, Clone, Copy, PartialEq, Eq, thiserror::Error)]
#[error("Invalid Parameter")]
pub struct InvalidParamException;
impl From<InvalidParamException> for SteamError {
fn from(value: InvalidParamException) -> Self {
SteamError::InvalidArgument(value.to_string())
}
}
pub trait ICodeProgress {
fn set_progress(&mut self, in_size: i64, out_size: i64);
}
pub trait ICoder {
fn code(
&mut self,
in_stream: Vec<u8>,
out_stream: &mut Vec<u8>,
in_size: i64,
out_size: i64,
progress: Option<&mut dyn ICodeProgress>,
) -> Result<(), SteamError>;
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum CoderPropID {
DefaultProp = 0,
DictionarySize,
UsedMemorySize,
Order,
BlockSize,
PosStateBits,
LitContextBits,
LitPosBits,
NumFastBytes,
MatchFinder,
MatchFinderCycles,
NumPasses,
Algorithm,
NumThreads,
EndMarker,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum CoderProperty {
Int32(i32),
UInt32(u32),
Boolean(bool),
String(String),
}
impl CoderProperty {
pub fn as_i32(&self) -> Option<i32> {
match self {
CoderProperty::Int32(v) => Some(*v),
CoderProperty::UInt32(v) => Some(*v as i32),
_ => None,
}
}
pub fn as_bool(&self) -> Option<bool> {
match self {
CoderProperty::Boolean(v) => Some(*v),
_ => None,
}
}
pub fn as_str(&self) -> Option<&str> {
match self {
CoderProperty::String(v) => Some(v.as_str()),
_ => None,
}
}
}
pub trait ISetCoderProperties {
fn set_coder_properties(
&mut self,
prop_ids: &[CoderPropID],
properties: &[CoderProperty],
) -> Result<(), InvalidParamException>;
}
pub trait IWriteCoderProperties {
fn write_coder_properties(&mut self, out_stream: &mut Vec<u8>);
}