pub struct SourceFile {
pub id: String,
pub format: String,
pub tokens: Vec<Token>,
pub bytes: u64,
}Expand description
A source file with pre-tokenized tokens, ready for clone detection.
Fields§
§id: String§format: String§tokens: Vec<Token>§bytes: u64File size in bytes. Zero for synthetic sub-format sources (embedded code blocks) whose bytes are counted by the parent file.
Implementations§
Source§impl SourceFile
impl SourceFile
Sourcepub fn is_embedded(&self) -> bool
pub fn is_embedded(&self) -> bool
True for a synthetic sub-format source: one embedded language inside a
host file, stored under <path>:<format> (issue #1090). Its tokens keep
the host file’s line numbers, so the lines between two blocks belong to
the host and not to this format.
Sourcepub fn line_count(&self) -> u64
pub fn line_count(&self) -> u64
Lines of this source that carry code of its own format. For an ordinary file that is the last line holding a token — near enough to the file’s length, and what jscpd has always counted. For an embedded block it is only the lines the blocks themselves occupy.
Trait Implementations§
Source§impl Clone for SourceFile
impl Clone for SourceFile
Source§impl Debug for SourceFile
impl Debug for SourceFile
Source§impl<'de> Deserialize<'de> for SourceFile
impl<'de> Deserialize<'de> for SourceFile
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 SourceFile
Source§impl PartialEq for SourceFile
impl PartialEq for SourceFile
Source§impl Serialize for SourceFile
impl Serialize for SourceFile
impl StructuralPartialEq for SourceFile
Auto Trait Implementations§
impl Freeze for SourceFile
impl RefUnwindSafe for SourceFile
impl Send for SourceFile
impl Sync for SourceFile
impl Unpin for SourceFile
impl UnsafeUnpin for SourceFile
impl UnwindSafe for SourceFile
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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