pub trait ApiDetect: Api {
// Required method
fn detect(&self, text: String) -> Result<Option<Language>, Error>;
}Expand description
Extends Api to implement language detection.
Required Methods§
Sourcefn detect(&self, text: String) -> Result<Option<Language>, Error>
fn detect(&self, text: String) -> Result<Option<Language>, Error>
Detect the language of the selected text.
§Inputs
Takes in input only a String containing the text.
§Outputs
The method returns a Result<Option<Language>, Error> type:
- if the API was able to detect the language, it will result in an
Ok(Some(detected_language)). - if it failed to detect, it will be an
Ok(None). - if an error preventing the API to do the detection, it will return an error:
Error(returned_error).
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.