diff options
author | Genny <gen@nyble.dev> | 2021-03-08 21:02:50 -0600 |
---|---|---|
committer | Genny <gen@nyble.dev> | 2021-03-08 21:02:50 -0600 |
commit | a368be4dfb3c1f75f6bcfdc297fe0372fb5f6092 (patch) | |
tree | 73c85d0abc2b065d827beea5f69f28a93d74816a | |
parent | c54872f011c135bbbc963f4a2b6b1d8ee4fa92bc (diff) | |
download | gifed-a368be4dfb3c1f75f6bcfdc297fe0372fb5f6092.tar.gz gifed-a368be4dfb3c1f75f6bcfdc297fe0372fb5f6092.zip |
Rename a few things
-rw-r--r-- | src/block/block.rs | 9 | ||||
-rw-r--r-- | src/block/colortable.rs (renamed from src/components/colortable.rs) | 2 | ||||
-rw-r--r-- | src/block/image.rs (renamed from src/components/image.rs) | 0 | ||||
-rw-r--r-- | src/block/imagedescriptor.rs (renamed from src/components/imagedescriptor.rs) | 0 | ||||
-rw-r--r-- | src/block/mod.rs | 13 | ||||
-rw-r--r-- | src/block/screendescriptor.rs (renamed from src/components/logicalscreendescriptor.rs) | 8 | ||||
-rw-r--r-- | src/block/version.rs (renamed from src/components/version.rs) | 0 | ||||
-rw-r--r-- | src/color.rs (renamed from src/components/color.rs) | 0 | ||||
-rw-r--r-- | src/components/mod.rs | 15 | ||||
-rw-r--r-- | src/gif.rs (renamed from src/components/gif.rs) | 6 | ||||
-rw-r--r-- | src/lib.rs | 8 | ||||
-rw-r--r-- | src/writer/gifbuilder.rs | 9 | ||||
-rw-r--r-- | src/writer/imagebuilder.rs | 2 |
13 files changed, 42 insertions, 30 deletions
diff --git a/src/block/block.rs b/src/block/block.rs new file mode 100644 index 0000000..95ff12e --- /dev/null +++ b/src/block/block.rs @@ -0,0 +1,9 @@ +use crate::block::Version; + +use super::ScreenDescriptor; + + +pub enum Block { + Version(Version), + LogicalScreenDescriptor(ScreenDescriptor) +} \ No newline at end of file diff --git a/src/components/colortable.rs b/src/block/colortable.rs index f756169..97b428f 100644 --- a/src/components/colortable.rs +++ b/src/block/colortable.rs @@ -1,5 +1,5 @@ use std::ops::Deref; -pub use super::Color; +pub use crate::Color; pub struct ColorTable { table: Vec<Color> diff --git a/src/components/image.rs b/src/block/image.rs index 07f9555..07f9555 100644 --- a/src/components/image.rs +++ b/src/block/image.rs diff --git a/src/components/imagedescriptor.rs b/src/block/imagedescriptor.rs index c911baa..c911baa 100644 --- a/src/components/imagedescriptor.rs +++ b/src/block/imagedescriptor.rs diff --git a/src/block/mod.rs b/src/block/mod.rs new file mode 100644 index 0000000..049b39a --- /dev/null +++ b/src/block/mod.rs @@ -0,0 +1,13 @@ +mod block; +mod colortable; +mod image; +mod imagedescriptor; +mod screendescriptor; +mod version; + +pub use block::Block; +pub use colortable::ColorTable; +pub use image::Image; +pub use imagedescriptor::ImageDescriptor; +pub use screendescriptor::ScreenDescriptor; +pub use version::Version; \ No newline at end of file diff --git a/src/components/logicalscreendescriptor.rs b/src/block/screendescriptor.rs index b20c9d5..d53d252 100644 --- a/src/components/logicalscreendescriptor.rs +++ b/src/block/screendescriptor.rs @@ -1,4 +1,4 @@ -pub struct LogicalScreenDescriptor { +pub struct ScreenDescriptor { pub width: u16, pub height: u16, pub packed: u8, @@ -6,7 +6,7 @@ pub struct LogicalScreenDescriptor { pub pixel_aspect_ratio: u8 } -impl LogicalScreenDescriptor { +impl ScreenDescriptor { pub fn color_table_present(&mut self, is_present: bool) { if is_present { self.packed |= 0b1000_0000; @@ -26,8 +26,8 @@ impl LogicalScreenDescriptor { //TODO: Setter for color resolution in packed field } -impl From<&LogicalScreenDescriptor> for Box<[u8]> { - fn from(lsd: &LogicalScreenDescriptor) -> Self { +impl From<&ScreenDescriptor> for Box<[u8]> { + fn from(lsd: &ScreenDescriptor) -> Self { let mut vec = vec![]; vec.extend_from_slice(&lsd.width.to_le_bytes()); vec.extend_from_slice(&lsd.height.to_le_bytes()); diff --git a/src/components/version.rs b/src/block/version.rs index a5d688d..a5d688d 100644 --- a/src/components/version.rs +++ b/src/block/version.rs diff --git a/src/components/color.rs b/src/color.rs index dc134ef..dc134ef 100644 --- a/src/components/color.rs +++ b/src/color.rs diff --git a/src/components/mod.rs b/src/components/mod.rs deleted file mode 100644 index 1650d36..0000000 --- a/src/components/mod.rs +++ /dev/null @@ -1,15 +0,0 @@ -mod color; -mod colortable; -mod gif; -mod image; -mod imagedescriptor; -mod logicalscreendescriptor; -mod version; - -pub use color::Color; -pub use colortable::ColorTable; -pub use gif::Gif; -pub use image::Image; -pub use imagedescriptor::ImageDescriptor; -pub use logicalscreendescriptor::LogicalScreenDescriptor; -pub use version::Version; \ No newline at end of file diff --git a/src/components/gif.rs b/src/gif.rs index 2709fe8..c3ef56b 100644 --- a/src/components/gif.rs +++ b/src/gif.rs @@ -1,8 +1,8 @@ -use super::{ColorTable, Image, LogicalScreenDescriptor, Version}; +use crate::block::{ColorTable, Image, ScreenDescriptor, Version}; pub struct Gif { pub header: Version, - pub logical_screen_descriptor: LogicalScreenDescriptor, + pub screen_descriptor: ScreenDescriptor, pub global_color_table: Option<ColorTable>, pub images: Vec<Image> // Trailer at the end of this struct is 0x3B // @@ -14,7 +14,7 @@ impl Gif { out.extend_from_slice((&self.header).into()); - let mut boxed: Box<[u8]> = (&self.logical_screen_descriptor).into(); + let mut boxed: Box<[u8]> = (&self.screen_descriptor).into(); out.extend_from_slice(&*boxed); // While we output the color table, grab it's length to use when diff --git a/src/lib.rs b/src/lib.rs index 6eb07d6..5ef22af 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,10 @@ -mod components; +mod color; +mod gif; mod lzw; + +pub mod block; pub mod writer; -pub use components::*; +pub use color::Color; +pub use gif::Gif; pub use lzw::LZW; \ No newline at end of file diff --git a/src/writer/gifbuilder.rs b/src/writer/gifbuilder.rs index 6ae55d5..415ebf6 100644 --- a/src/writer/gifbuilder.rs +++ b/src/writer/gifbuilder.rs @@ -1,5 +1,6 @@ -use crate::components::{ColorTable, Gif, LogicalScreenDescriptor, Version}; -use super::ImageBuilder; +use crate::block::{ColorTable, ScreenDescriptor, Version}; +use crate::writer::ImageBuilder; +use crate::Gif; pub struct GifBuilder { version: Version, @@ -44,7 +45,7 @@ impl GifBuilder { } pub fn build(self) -> Gif { - let mut lsd = LogicalScreenDescriptor { + let mut lsd = ScreenDescriptor { width: self.width, height: self.height, packed: 0, // Set later @@ -64,7 +65,7 @@ impl GifBuilder { Gif { header: self.version, - logical_screen_descriptor: lsd, + screen_descriptor: lsd, global_color_table: self.global_color_table, images } diff --git a/src/writer/imagebuilder.rs b/src/writer/imagebuilder.rs index 0636bb3..d8b9900 100644 --- a/src/writer/imagebuilder.rs +++ b/src/writer/imagebuilder.rs @@ -1,4 +1,4 @@ -use crate::components::{ColorTable, Image, ImageDescriptor}; +use crate::block::{ColorTable, Image, ImageDescriptor}; pub struct ImageBuilder { left_offset: u16, |