pub struct IMF {
pub version: u8,
pub colors: BTreeMap<i32, (u8, u8, u8)>,
pub width: usize,
pub height: usize,
pub map: Vec<i32>,
}Expand description
Stores the version, colors, width, height and content of an Integer Media File.
Fields§
§version: u8§colors: BTreeMap<i32, (u8, u8, u8)>§width: usize§height: usize§map: Vec<i32>Implementations§
source§impl IMF
impl IMF
sourcepub fn new(path: &str) -> Result<IMF, String>
pub fn new(path: &str) -> Result<IMF, String>
Creates new IMF from file located at filepath. If you want to create a new one from existing variables, declare it like this:
use imf::IMF;
//assuming that all variables already exist
let imf = IMF {
version,
colors,
width,
height,
map
};sourcepub fn get_xy(&self, x: usize, y: usize) -> Option<i32>
pub fn get_xy(&self, x: usize, y: usize) -> Option<i32>
Returns number found at coordinates within IMF.
See IMF::set_xy
§Arguments
x- The X coordinatey- The Y coordinate
§Example
use imf::IMF;
//example.imf:
//1,0,1,5,
//4,7,3,3,
//9,2,5,6,
//0,5,8,2
let mut imf = IMF::new("example.imf").unwrap();
let n = imf.get_xy(1,1).unwrap();
// n == 7sourcepub fn set_xy(&mut self, x: usize, y: usize, i: i32) -> bool
pub fn set_xy(&mut self, x: usize, y: usize, i: i32) -> bool
Sets number at coordinates within IMF to the number specified.
See IMF::get_xy
§Arguments
x- The X coordinatey- The Y coordinatei- What the number will be set to
§Example
use imf::IMF;
let mut imf = IMF::new("example.imf").unwrap();
imf.set_xy(2,2,5);
// imf.get_xy(2,2) == 5Trait Implementations§
Auto Trait Implementations§
impl Freeze for IMF
impl RefUnwindSafe for IMF
impl Send for IMF
impl Sync for IMF
impl Unpin for IMF
impl UnwindSafe for IMF
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit)