pub struct Buffer {
pub id: Option<i64>,
pub name: Option<String>,
pub source: Option<PathBuf>,
pub content: String,
pub metadata: BufferMetadata,
}Expand description
Represents a text buffer in the RLM system.
Buffers are the primary unit of content storage, containing text that can be chunked and processed by the RLM workflow.
§Examples
use rlm_rs::core::Buffer;
let buffer = Buffer::from_content("Hello, world!".to_string());
assert_eq!(buffer.size(), 13);Fields§
§id: Option<i64>Unique identifier (assigned by storage layer).
name: Option<String>Optional name for the buffer.
source: Option<PathBuf>Source file path (if loaded from file).
content: StringBuffer content.
metadata: BufferMetadataBuffer metadata.
Implementations§
Source§impl Buffer
impl Buffer
Sourcepub fn from_content(content: String) -> Self
pub fn from_content(content: String) -> Self
Sourcepub fn from_file(path: PathBuf, content: String) -> Self
pub fn from_file(path: PathBuf, content: String) -> Self
Creates a new buffer from a file path and content.
§Arguments
path- Path to the source file.content- The text content read from the file.
§Examples
use rlm_rs::core::Buffer;
use std::path::PathBuf;
let buffer = Buffer::from_file(
PathBuf::from("example.txt"),
"File content".to_string(),
);
assert!(buffer.source.is_some());Sourcepub fn from_named(name: String, content: String) -> Self
pub fn from_named(name: String, content: String) -> Self
Creates a new named buffer from content.
§Arguments
name- Name for the buffer.content- The text content for the buffer.
Sourcepub fn line_count(&mut self) -> usize
pub fn line_count(&mut self) -> usize
Returns the line count of the buffer.
This is computed on first call and cached.
Sourcepub fn peek(&self, len: usize) -> &str
pub fn peek(&self, len: usize) -> &str
Returns a peek of the buffer content from the beginning.
§Arguments
len- Maximum number of bytes to return.
Sourcepub fn peek_end(&self, len: usize) -> &str
pub fn peek_end(&self, len: usize) -> &str
Returns a peek of the buffer content from the end.
§Arguments
len- Maximum number of bytes to return.
Sourcepub fn display_name(&self) -> String
pub fn display_name(&self) -> String
Returns the display name for this buffer.
Sourcepub fn set_chunk_count(&mut self, count: usize)
pub fn set_chunk_count(&mut self, count: usize)
Sets the chunk count after chunking.
Sourcepub fn compute_hash(&mut self)
pub fn compute_hash(&mut self)
Computes and sets the content hash.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Buffer
impl<'de> Deserialize<'de> for Buffer
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Buffer
impl StructuralPartialEq for Buffer
Auto Trait Implementations§
impl Freeze for Buffer
impl RefUnwindSafe for Buffer
impl Send for Buffer
impl Sync for Buffer
impl Unpin for Buffer
impl UnwindSafe for Buffer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more