make Str public
This commit is contained in:
parent
2984c3244c
commit
b01343ebfb
@ -6,7 +6,7 @@ use crate::{
|
|||||||
|
|
||||||
#[derive(Clone, Copy, FromBytes, FromZeroes, AsBytes, Unaligned)]
|
#[derive(Clone, Copy, FromBytes, FromZeroes, AsBytes, Unaligned)]
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
struct Str {
|
pub struct Str {
|
||||||
data: FileRange,
|
data: FileRange,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -19,7 +19,7 @@ impl Str {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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() {
|
let data = if s.is_empty() {
|
||||||
Str::new().data
|
Str::new().data
|
||||||
} else {
|
} else {
|
||||||
@ -35,20 +35,20 @@ impl Str {
|
|||||||
Str { data }
|
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()
|
std::str::from_utf8(reader.read_raw(self.data)).unwrap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FilePointer<Str> {
|
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 new_str = transaction.read::<Str>(self).set(transaction, s);
|
||||||
let (ptr, data) = transaction.modify(self);
|
let (ptr, data) = transaction.modify(self);
|
||||||
*data = new_str;
|
*data = new_str;
|
||||||
ptr
|
ptr
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get(self, reader: &impl ReaderTrait) -> &str {
|
pub fn get(self, reader: &impl ReaderTrait) -> &str {
|
||||||
reader.read(self).get(reader)
|
reader.read(self).get(reader)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user