pub struct FileView {
pub content: ViewerContent,
pub truncated: bool,
pub language: Option<Language>,
}Expand description
A file prepared for read-only viewing.
Fields§
§content: ViewerContent§truncated: boolWhether the file held more than what content shows.
language: Option<Language>The language detected for text content, if any.
Implementations§
Source§impl FileView
impl FileView
Sourcepub fn from_bytes(bytes: &[u8]) -> Self
pub fn from_bytes(bytes: &[u8]) -> Self
Classify up to MAX_VIEW_BYTES of bytes and prepare them for
display, flagging truncation when more was supplied than that.
Callers that read from a real file should hand over MAX_VIEW_BYTES + 1
bytes: the one extra byte is what distinguishes a file that exactly
fills the cap from one that overruns it.
Sourcepub fn from_file(name: &str, bytes: &[u8]) -> Self
pub fn from_file(name: &str, bytes: &[u8]) -> Self
Self::from_bytes, plus the language of text content, judged from
the file’s name and its first line.
pub const fn is_binary(&self) -> bool
Sourcepub fn line_count(&self) -> usize
pub fn line_count(&self) -> usize
How many lines the body occupies, for sizing the viewer’s scroll.
Trait Implementations§
impl Eq for FileView
impl StructuralPartialEq for FileView
Auto Trait Implementations§
impl Forget for FileView
impl Freeze for FileView
impl Move for FileView
impl RefUnwindSafe for FileView
impl Send for FileViewwhere
RawVecInner: Send,
impl Sync for FileViewwhere
RawVecInner: Sync,
impl Unpin for FileView
impl UnsafeUnpin for FileView
impl UnwindSafe for FileViewwhere
RawVecInner: UnwindSafe,
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§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.