pub struct LanguageProfile { /* private fields */ }Expand description
Per-language capability profile for restricting transforms to supported features.
Implementations§
Source§impl LanguageProfile
impl LanguageProfile
Sourcepub fn new(name: impl Into<String>, language: impl Into<String>) -> Self
pub fn new(name: impl Into<String>, language: impl Into<String>) -> Self
Creates an empty profile for a target language.
Sourcepub fn javascript() -> Self
pub fn javascript() -> Self
Built-in JavaScript same-language profile.
Sourcepub fn from_rule_set(
name: impl Into<String>,
language: impl Into<String>,
rule_set: &TranslationRuleSet,
) -> Self
pub fn from_rule_set( name: impl Into<String>, language: impl Into<String>, rule_set: &TranslationRuleSet, ) -> Self
Computes a profile domain from a translation rule set.
Rule query link-type filters become supported link types, query term filters become supported concept/feature terms, and every rule name is recorded as a supported translation rule.
Sourcepub const fn link_types(&self) -> &BTreeSet<LinkType>
pub const fn link_types(&self) -> &BTreeSet<LinkType>
Supported link types.
Sourcepub const fn translation_rules(&self) -> &BTreeSet<String>
pub const fn translation_rules(&self) -> &BTreeSet<String>
Supported translation rule names.
Sourcepub const fn fallbacks(&self) -> &BTreeMap<String, String>
pub const fn fallbacks(&self) -> &BTreeMap<String, String>
Unsupported concepts mapped to their documented lossy fallback.
Each entry records a concept the target cannot represent natively
together with the fallback applied when the concept is encountered (for
example a heading rendered as a plain paragraph in txt). This is the
per-target fidelity report required by issue #86.
Sourcepub fn with_link_type(self, link_type: LinkType) -> Self
pub fn with_link_type(self, link_type: LinkType) -> Self
Returns a copy with a supported link type.
Sourcepub fn with_concept(self, concept: impl Into<String>) -> Self
pub fn with_concept(self, concept: impl Into<String>) -> Self
Returns a copy with a supported concept or feature term.
Sourcepub fn with_translation_rule(self, rule: impl Into<String>) -> Self
pub fn with_translation_rule(self, rule: impl Into<String>) -> Self
Returns a copy with a supported translation rule name.
Sourcepub fn with_concept_fallback(
self,
concept: impl Into<String>,
fallback: impl Into<String>,
) -> Self
pub fn with_concept_fallback( self, concept: impl Into<String>, fallback: impl Into<String>, ) -> Self
Returns a copy that records an unsupported concept and its lossy fallback.
Use this to declare features the target cannot represent natively, so the profile can report them as documented lossy fallbacks rather than silent data loss.
Sourcepub fn concept_fallback(&self, concept: &str) -> Option<&str>
pub fn concept_fallback(&self, concept: &str) -> Option<&str>
The documented lossy fallback for a concept the target cannot represent,
or None when the concept is natively supported or unknown.
Sourcepub fn supports_link_type(&self, link_type: LinkType) -> bool
pub fn supports_link_type(&self, link_type: LinkType) -> bool
Whether this profile supports a link type.
Sourcepub fn supports_concept(&self, concept: &str) -> bool
pub fn supports_concept(&self, concept: &str) -> bool
Whether this profile supports a concept or feature term.
Sourcepub fn supports_translation_rule(&self, rule: &str) -> bool
pub fn supports_translation_rule(&self, rule: &str) -> bool
Whether this profile supports a translation rule name.
Sourcepub fn declare_in(&self, network: &mut LinkNetwork) -> LanguageProfileLinks
pub fn declare_in(&self, network: &mut LinkNetwork) -> LanguageProfileLinks
Declares this profile as queryable links inside a network.
Sourcepub fn validate_network(
&self,
network: &LinkNetwork,
) -> Result<(), LanguageProfileViolation>
pub fn validate_network( &self, network: &LinkNetwork, ) -> Result<(), LanguageProfileViolation>
Validates that all typed links in a network stay inside this profile.
§Errors
Returns LanguageProfileViolation for the first unsupported link
type found in identifier order.
Trait Implementations§
Source§impl Clone for LanguageProfile
impl Clone for LanguageProfile
Source§fn clone(&self) -> LanguageProfile
fn clone(&self) -> LanguageProfile
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for LanguageProfile
impl Debug for LanguageProfile
Source§impl PartialEq for LanguageProfile
impl PartialEq for LanguageProfile
impl Eq for LanguageProfile
impl StructuralPartialEq for LanguageProfile
Auto Trait Implementations§
impl Freeze for LanguageProfile
impl RefUnwindSafe for LanguageProfile
impl Send for LanguageProfile
impl Sync for LanguageProfile
impl Unpin for LanguageProfile
impl UnsafeUnpin for LanguageProfile
impl UnwindSafe for LanguageProfile
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
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>
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>
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