pub struct FileSnapshot {
pub path: PathBuf,
pub hash: String,
pub size: u64,
pub modified_at: DateTime<Utc>,
pub generated_regions: Vec<Region>,
pub manual_regions: Vec<Region>,
}Expand description
Snapshot of file state
Captures the state of a generated file, including its content hash, size, modification time, and regions (generated vs manual).
§Examples
use ggen_core::snapshot::FileSnapshot;
use std::path::PathBuf;
let path = PathBuf::from("output.rs");
let content = "fn main() { println!(\"Hello\"); }";
let snapshot = FileSnapshot::new(path.clone(), content.to_string())?;
assert_eq!(snapshot.path, path);
assert!(!snapshot.hash.is_empty());
// Check if content has changed
assert!(!snapshot.has_changed(content));
assert!(snapshot.has_changed("different content"));Fields§
§path: PathBufPath to the file
hash: StringHash of the file content
size: u64File size in bytes
modified_at: DateTime<Utc>When the file was last modified
generated_regions: Vec<Region>Generated regions in the file (for three-way merge)
manual_regions: Vec<Region>Manual regions in the file (for three-way merge)
Implementations§
Source§impl FileSnapshot
impl FileSnapshot
Sourcepub fn has_changed(&self, new_content: &str) -> bool
pub fn has_changed(&self, new_content: &str) -> bool
Check if file content has changed
Compares the hash of new content with the snapshot’s hash.
Returns true if the content has changed since the snapshot was taken.
§Examples
use ggen_core::snapshot::FileSnapshot;
use std::path::PathBuf;
let snapshot = FileSnapshot::new(
PathBuf::from("file.rs"),
"original content".to_string()
)?;
assert!(!snapshot.has_changed("original content"));
assert!(snapshot.has_changed("modified content"));Trait Implementations§
Source§impl Clone for FileSnapshot
impl Clone for FileSnapshot
Source§fn clone(&self) -> FileSnapshot
fn clone(&self) -> FileSnapshot
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for FileSnapshot
impl Debug for FileSnapshot
Source§impl<'de> Deserialize<'de> for FileSnapshot
impl<'de> Deserialize<'de> for FileSnapshot
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
Auto Trait Implementations§
impl Freeze for FileSnapshot
impl RefUnwindSafe for FileSnapshot
impl Send for FileSnapshot
impl Sync for FileSnapshot
impl Unpin for FileSnapshot
impl UnwindSafe for FileSnapshot
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<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request