From b4a86dca9f3be91f8a9c1ca727847f1ed091fb01 Mon Sep 17 00:00:00 2001 From: niku Date: Sun, 13 Aug 2023 13:17:09 +0200 Subject: [PATCH] Added Position type for cursor --- src/pager.rs | 2 +- src/table.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pager.rs b/src/pager.rs index 8ce2745..05636b2 100644 --- a/src/pager.rs +++ b/src/pager.rs @@ -42,7 +42,7 @@ impl Pager { metadata.len() as usize } - pub fn row_location(&self, row_num: usize) -> (usize, usize) { + pub fn row_location(&self, row_num: usize) -> Position { let page_num = row_num / ROWS_PER_PAGE; let row_offset = row_num % ROWS_PER_PAGE; let byte_offset = row_offset * ROW_SIZE; diff --git a/src/table.rs b/src/table.rs index 856095a..387e253 100644 --- a/src/table.rs +++ b/src/table.rs @@ -1,4 +1,4 @@ -use crate::{layout::*, pager::Pager}; +use crate::{cursor::Position, layout::*, pager::Pager}; pub struct Table { pub row_count: usize, @@ -11,7 +11,7 @@ impl Table { Self { row_count, pager } } - pub fn row_slot(&self, index: usize) -> (usize, usize) { + pub fn row_slot(&self, index: usize) -> Position { self.pager.row_location(index) }