make Str public

This commit is contained in:
soruh 2023-08-14 17:14:47 +02:00
parent 2984c3244c
commit b01343ebfb

View File

@ -6,7 +6,7 @@ use crate::{
#[derive(Clone, Copy, FromBytes, FromZeroes, AsBytes, Unaligned)]
#[repr(transparent)]
struct Str {
pub struct Str {
data: FileRange,
}
@ -19,7 +19,7 @@ impl Str {
}
impl Str {
fn set<R>(self, transaction: &mut TransactionHandle<R>, s: &str) -> Self {
pub fn set<R>(self, transaction: &mut TransactionHandle<R>, s: &str) -> Self {
let data = if s.is_empty() {
Str::new().data
} else {
@ -35,20 +35,20 @@ impl Str {
Str { data }
}
fn get(self, reader: &impl ReaderTrait) -> &str {
pub fn get(self, reader: &impl ReaderTrait) -> &str {
std::str::from_utf8(reader.read_raw(self.data)).unwrap()
}
}
impl FilePointer<Str> {
fn set<R>(self, transaction: &mut TransactionHandle<R>, s: &str) -> FilePointer<Str> {
pub fn set<R>(self, transaction: &mut TransactionHandle<R>, s: &str) -> FilePointer<Str> {
let new_str = transaction.read::<Str>(self).set(transaction, s);
let (ptr, data) = transaction.modify(self);
*data = new_str;
ptr
}
fn get(self, reader: &impl ReaderTrait) -> &str {
pub fn get(self, reader: &impl ReaderTrait) -> &str {
reader.read(self).get(reader)
}
}