[−][src]Enum tokei::LanguageType
Represents a individual programming language. Can be used to provide information about the language, such as multi line comments, single line comments, string literal syntax, whether a given language allows nesting comments.
Variants (Non-exhaustive)
Implementations
impl LanguageType
[src]
pub fn name(self) -> &'static str
[src]
Returns the display name of a language.
let bash = LanguageType::Bash; assert_eq!(bash.name(), "BASH");
pub fn list() -> &'static [Self]
[src]
Provides every variant in a Vec
pub fn line_comments(self) -> &'static [&'static str]
[src]
Returns the single line comments of a language.
use tokei::LanguageType; let lang = LanguageType::Rust; assert_eq!(lang.line_comments(), &["//"]);
pub fn multi_line_comments(self) -> &'static [(&'static str, &'static str)]
[src]
Returns the single line comments of a language.
use tokei::LanguageType; let lang = LanguageType::Rust; assert_eq!(lang.multi_line_comments(), &[("/*", "*/")]);
pub fn allows_nested(self) -> bool
[src]
Returns whether the language allows nested multi line comments.
use tokei::LanguageType; let lang = LanguageType::Rust; assert!(lang.allows_nested());
pub fn nested_comments(self) -> &'static [(&'static str, &'static str)]
[src]
Returns what nested comments the language has. (Currently only D has any of this type.)
use tokei::LanguageType; let lang = LanguageType::D; assert_eq!(lang.nested_comments(), &[("/+", "+/")]);
pub fn quotes(self) -> &'static [(&'static str, &'static str)]
[src]
Returns the quotes of a language.
use tokei::LanguageType; let lang = LanguageType::C; assert_eq!(lang.quotes(), &[("\"", "\"")]);
pub fn doc_quotes(self) -> &'static [(&'static str, &'static str)]
[src]
Returns the doc quotes of a language.
use tokei::LanguageType; let lang = LanguageType::Python; assert_eq!(lang.doc_quotes(), &[("\"\"\"", "\"\"\""), ("'''", "'''")]);
pub fn shebangs(self) -> &'static [&'static str]
[src]
Returns the shebang of a language.
use tokei::LanguageType; let lang = LanguageType::Bash; assert_eq!(lang.shebangs(), &["#!/bin/bash"]);
pub fn important_syntax(self) -> &'static [&'static str]
[src]
Returns the parts of syntax that determines whether tokei can skip large parts of analysis.
pub fn from_path<P: AsRef<Path>>(entry: P, _config: &Config) -> Option<Self>
[src]
Get language from a file path. May open and read the file.
use tokei::{Config, LanguageType}; let rust = LanguageType::from_path("./main.rs", &Config::default()); assert_eq!(rust, Some(LanguageType::Rust));
pub fn from_file_extension(extension: &str) -> Option<Self>
[src]
Get language from a file extension.
use tokei::LanguageType; let rust = LanguageType::from_file_extension("rs"); assert_eq!(rust, Some(LanguageType::Rust));
pub fn from_shebang<P: AsRef<Path>>(entry: P) -> Option<Self>
[src]
Get language from a shebang. May open and read the file.
use tokei::LanguageType; let rust = LanguageType::from_shebang("./main.rs"); assert_eq!(rust, Some(LanguageType::Rust));
impl LanguageType
[src]
pub fn parse(
self,
path: PathBuf,
config: &Config
) -> Result<Stats, (Error, PathBuf)>
[src]
self,
path: PathBuf,
config: &Config
) -> Result<Stats, (Error, PathBuf)>
Parses a given Path
using the LanguageType
. Returning Stats
on success and giving back ownership of PathBuf on error.
pub fn parse_from_str<A: AsRef<str>>(
self,
path: PathBuf,
text: A,
config: &Config
) -> Stats
[src]
self,
path: PathBuf,
text: A,
config: &Config
) -> Stats
Parses the text provided. Returns Stats
on success.
pub fn parse_from_slice<A: AsRef<[u8]>>(
self,
path: PathBuf,
text: A,
config: &Config
) -> Stats
[src]
self,
path: PathBuf,
text: A,
config: &Config
) -> Stats
Parses the text provided. Returning Stats
on success.
Trait Implementations
impl Clone for LanguageType
[src]
fn clone(&self) -> LanguageType
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for LanguageType
[src]
impl Debug for LanguageType
[src]
impl<'de> Deserialize<'de> for LanguageType
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl Display for LanguageType
[src]
impl Eq for LanguageType
[src]
impl<'a> From<&'a LanguageType> for Cow<'a, LanguageType>
[src]
fn from(from: &'a LanguageType) -> Self
[src]
impl<'a> From<LanguageType> for Cow<'a, LanguageType>
[src]
fn from(from: LanguageType) -> Self
[src]
impl FromStr for LanguageType
[src]
type Err = &'static str
The associated error which can be returned from parsing.
fn from_str(from: &str) -> Result<Self, Self::Err>
[src]
impl Hash for LanguageType
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl Ord for LanguageType
[src]
fn cmp(&self, other: &LanguageType) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl PartialEq<LanguageType> for LanguageType
[src]
fn eq(&self, other: &LanguageType) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl PartialOrd<LanguageType> for LanguageType
[src]
fn partial_cmp(&self, other: &LanguageType) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl Serialize for LanguageType
[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl StructuralEq for LanguageType
[src]
impl StructuralPartialEq for LanguageType
[src]
Auto Trait Implementations
impl RefUnwindSafe for LanguageType
impl Send for LanguageType
impl Sync for LanguageType
impl Unpin for LanguageType
impl UnwindSafe for LanguageType
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,