From 591556b7a40c2c844e25f8b04780d08277d5356e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Kr=C3=BCger?= Date: Wed, 28 Feb 2024 13:49:31 +0100 Subject: [PATCH] refactor: Rename `get_size` -> `size` in `wnfs` crate --- wnfs/src/private/file.rs | 18 +++++------------- wnfs/src/public/file.rs | 6 +++--- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/wnfs/src/private/file.rs b/wnfs/src/private/file.rs index a820de22..7b589384 100644 --- a/wnfs/src/private/file.rs +++ b/wnfs/src/private/file.rs @@ -617,21 +617,17 @@ impl PrivateFile { /// ) /// .await?; /// - /// let mut size = file.get_size(forest, store).await?; + /// let mut size = file.size(forest, store).await?; /// - /// assert_eq!(content.len(), size); + /// assert_eq!(content.len() as u64, size); /// /// Ok(()) /// } /// ``` - pub async fn get_size( - &self, - forest: &impl PrivateForest, - store: &impl BlockStore, - ) -> Result { + pub async fn size(&self, forest: &impl PrivateForest, store: &impl BlockStore) -> Result { match &self.content.content { FileContent::Inline { data } => Ok(data.len() as u64), - FileContent::External(forest_content) => forest_content.get_size(forest, store).await, + FileContent::External(forest_content) => forest_content.size(forest, store).await, } } @@ -1088,11 +1084,7 @@ impl PrivateForestContent { } /// Gets the exact size of the content. - pub async fn get_size( - &self, - forest: &impl PrivateForest, - store: &impl BlockStore, - ) -> Result { + pub async fn size(&self, forest: &impl PrivateForest, store: &impl BlockStore) -> Result { let size_without_last_block = std::cmp::max(0, self.block_count - 1) * self.block_content_size; diff --git a/wnfs/src/public/file.rs b/wnfs/src/public/file.rs index 2979df2e..97bf841e 100644 --- a/wnfs/src/public/file.rs +++ b/wnfs/src/public/file.rs @@ -335,14 +335,14 @@ impl PublicFile { /// ) /// .await?; /// - /// let mut size = file.get_size(store).await?; + /// let mut size = file.size(store).await?; /// - /// assert_eq!(content.len(), size); + /// assert_eq!(content.len() as u64, size); /// /// Ok(()) /// } /// ``` - pub async fn get_size(&self, store: &impl BlockStore) -> Result { + pub async fn size(&self, store: &impl BlockStore) -> Result { let value = self.userland.resolve_value(store).await?; Ok(value.filesize().unwrap_or(0)) }