From e0762612e95b0816721165c5aba6189809fcde58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Tue, 27 Oct 2026 22:08:47 +0100 Subject: ByteString conversion classes --- src/Erebos/Object/Internal.hs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/Erebos/Object') diff --git a/src/Erebos/Object/Internal.hs b/src/Erebos/Object/Internal.hs index 4a33dba..6f6fe6b 100644 --- a/src/Erebos/Object/Internal.hs +++ b/src/Erebos/Object/Internal.hs @@ -73,6 +73,7 @@ import Data.Word import System.IO.Unsafe +import ConvertByteString import Crypto import Erebos.Error import Erebos.Storage.Internal @@ -92,9 +93,9 @@ instance Eq (Ref' c) where instance Show (Ref' c) where show ref@(Ref st _) = show st ++ ":" ++ BC.unpack (showRef ref) -instance BA.ByteArrayAccess (Ref' c) where - length (Ref _ dgst) = BA.length dgst - withByteArray (Ref _ dgst) = BA.withByteArray dgst +instance ToByteString (Ref' c) where + withByteArray (Ref _ dgst) = withByteArray dgst + toByteString (Ref _ dgst) = toByteString dgst instance Hashable (Ref' c) where hashWithSalt salt = hashWithSalt salt . refDigest @@ -117,7 +118,7 @@ zeroRef s = Ref s (RefDigest h) digestAlgo = undefined isZeroRef :: Ref' c -> Bool -isZeroRef (Ref _ h) = all (==0) $ BA.unpack h +isZeroRef (Ref _ h) = all (== 0) $ B.unpack $ toByteString h refFromDigest :: Storage' c -> RefDigest -> IO (Maybe (Ref' c)) -- cgit v1.2.3