mirror of
https://github.com/lifegpc/pixiv_downloader.git
synced 2026-07-08 01:32:41 +08:00
Update
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
use proc_macros::define_struct_reader_fn;
|
||||
use proc_macros::define_struct_writer_fn;
|
||||
use proc_macros::impl_struct_reader_read;
|
||||
use proc_macros::impl_struct_writer_write;
|
||||
use std::io::Read;
|
||||
use std::io::Write;
|
||||
|
||||
/// Read number.
|
||||
pub trait StructRead {
|
||||
@@ -57,3 +60,37 @@ pub trait ClearFile {
|
||||
/// Clear all datas in file
|
||||
fn clear_file(&mut self) -> std::io::Result<()>;
|
||||
}
|
||||
|
||||
/// Write number.
|
||||
pub trait StructWrite {
|
||||
/// The error type
|
||||
type Error;
|
||||
define_struct_writer_fn!(u8);
|
||||
define_struct_writer_fn!(i8);
|
||||
define_struct_writer_fn!(u16);
|
||||
define_struct_writer_fn!(i16);
|
||||
define_struct_writer_fn!(u32);
|
||||
define_struct_writer_fn!(i32);
|
||||
define_struct_writer_fn!(u64);
|
||||
define_struct_writer_fn!(i64);
|
||||
define_struct_writer_fn!(usize);
|
||||
define_struct_writer_fn!(isize);
|
||||
define_struct_writer_fn!(u128);
|
||||
define_struct_writer_fn!(i128);
|
||||
}
|
||||
|
||||
impl<T: Write> StructWrite for T {
|
||||
type Error = std::io::Error;
|
||||
impl_struct_writer_write!(u8);
|
||||
impl_struct_writer_write!(i8);
|
||||
impl_struct_writer_write!(u16);
|
||||
impl_struct_writer_write!(i16);
|
||||
impl_struct_writer_write!(u32);
|
||||
impl_struct_writer_write!(i32);
|
||||
impl_struct_writer_write!(u64);
|
||||
impl_struct_writer_write!(i64);
|
||||
impl_struct_writer_write!(usize);
|
||||
impl_struct_writer_write!(isize);
|
||||
impl_struct_writer_write!(u128);
|
||||
impl_struct_writer_write!(i128);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user