pub enum NamespaceRule {
Literal(ResolvedNamespace),
File,
FileRelative,
Folder,
FolderRelative,
}Expand description
Namespace selection rules for FTL file output.
Variants§
Literal(ResolvedNamespace)
A literal namespace string.
File
Use the source file name (stem only) as the namespace.
FileRelative
Use the file path relative to the crate root as the namespace.
Folder
Use the source file parent folder name as the namespace.
FolderRelative
Use the source file parent folder path relative to crate root as the namespace.
Implementations§
Source§impl NamespaceRule
impl NamespaceRule
Sourcepub fn literal(namespace: impl Into<String>) -> Result<Self, NamespacePathError>
pub fn literal(namespace: impl Into<String>) -> Result<Self, NamespacePathError>
Creates a literal namespace rule after validating the namespace path.
Sourcepub fn resolve(&self, file_path: &str, manifest_dir: Option<&Path>) -> String
pub fn resolve(&self, file_path: &str, manifest_dir: Option<&Path>) -> String
Resolve the namespace string using the given file path.
Sourcepub fn try_resolve(
&self,
file_path: &str,
manifest_dir: Option<&Path>,
) -> Result<ResolvedNamespace, NamespacePathError>
pub fn try_resolve( &self, file_path: &str, manifest_dir: Option<&Path>, ) -> Result<ResolvedNamespace, NamespacePathError>
Resolve and validate the namespace string using the given file path.
Trait Implementations§
Source§impl Clone for NamespaceRule
impl Clone for NamespaceRule
Source§impl Debug for NamespaceRule
impl Debug for NamespaceRule
impl Eq for NamespaceRule
Source§impl FromMeta for NamespaceRule
impl FromMeta for NamespaceRule
Source§fn from_meta(item: &Meta) -> Result<Self>
fn from_meta(item: &Meta) -> Result<Self>
Create an instance from a
syn::Meta by dispatching to the format-appropriate
trait function. This generally should not be overridden by implementers. Read morefn from_nested_meta(item: &NestedMeta) -> Result<Self, Error>
Source§fn from_none() -> Option<Self>
fn from_none() -> Option<Self>
When a field is omitted from a parent meta-item,
from_none is used to attempt
recovery before a missing field error is generated. Read moreSource§fn from_word() -> Result<Self, Error>
fn from_word() -> Result<Self, Error>
Create an instance from the presence of the word in the attribute with no
additional options specified.
Source§fn from_list(items: &[NestedMeta]) -> Result<Self, Error>
fn from_list(items: &[NestedMeta]) -> Result<Self, Error>
Create an instance from a list of nested meta items.
Source§fn from_value(value: &Lit) -> Result<Self, Error>
fn from_value(value: &Lit) -> Result<Self, Error>
Create an instance from a literal value of either
foo = "bar" or foo("bar").
This dispatches to the appropriate method based on the type of literal encountered,
and generally should not be overridden by implementers. Read morefn from_expr(expr: &Expr) -> Result<Self, Error>
Source§fn from_invalid_expr(value: &MetaNameValueInvalidExpr) -> Result<Self, Error>
fn from_invalid_expr(value: &MetaNameValueInvalidExpr) -> Result<Self, Error>
Source§fn from_char(value: char) -> Result<Self, Error>
fn from_char(value: char) -> Result<Self, Error>
Create an instance from a char literal in a value position.
Source§impl Hash for NamespaceRule
impl Hash for NamespaceRule
Source§impl PartialEq for NamespaceRule
impl PartialEq for NamespaceRule
impl StructuralPartialEq for NamespaceRule
Auto Trait Implementations§
impl Freeze for NamespaceRule
impl RefUnwindSafe for NamespaceRule
impl Send for NamespaceRule
impl Sync for NamespaceRule
impl Unpin for NamespaceRule
impl UnsafeUnpin for NamespaceRule
impl UnwindSafe for NamespaceRule
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