pub trait DecoderWithCallback: Decoder {
// Provided methods
fn analyze_path_with_callback<P: AsRef<Path>, CallbackState>(
path: P,
callback: Sender<(P, AnalysisResult<Analysis>)>,
) { ... }
fn analyze_paths_with_callback<P: Into<PathBuf>, I: Send + IntoIterator<Item = P>>(
paths: I,
callback: Sender<(PathBuf, AnalysisResult<Analysis>)>,
) { ... }
fn analyze_paths_with_cores_with_callback<P: Into<PathBuf>, I: IntoIterator<Item = P>>(
paths: I,
number_cores: NonZeroUsize,
callback: Sender<(PathBuf, AnalysisResult<Analysis>)>,
) { ... }
}Expand description
This trait implements functions in the Decoder trait that take a callback to run on the results.
It should not be implemented directly, it will be automatically implemented for any type that implements
the Decoder trait.
Instead of sending an iterator of results, this trait sends each result over the provided channel as soon as it’s ready
Provided Methods§
Sourcefn analyze_path_with_callback<P: AsRef<Path>, CallbackState>(
path: P,
callback: Sender<(P, AnalysisResult<Analysis>)>,
)
fn analyze_path_with_callback<P: AsRef<Path>, CallbackState>( path: P, callback: Sender<(P, AnalysisResult<Analysis>)>, )
Returns a decoded song’s Analysis given a file path, or an error if the song
could not be analyzed for some reason.
§Arguments
path- APathholding a valid file path to a valid audio file.callback- A function that will be called with the path and the result of the analysis.
§Errors
This function will return an error if the file path is invalid, if the file path points to a file containing no or corrupted audio stream, or if the analysis could not be conducted to the end for some reason.
The error type returned should give a hint as to whether it was a decoding or an analysis error.
Sourcefn analyze_paths_with_callback<P: Into<PathBuf>, I: Send + IntoIterator<Item = P>>(
paths: I,
callback: Sender<(PathBuf, AnalysisResult<Analysis>)>,
)
fn analyze_paths_with_callback<P: Into<PathBuf>, I: Send + IntoIterator<Item = P>>( paths: I, callback: Sender<(PathBuf, AnalysisResult<Analysis>)>, )
Analyze songs in paths, and return the Analysis objects through an
mpsc::IntoIter.
Returns an iterator, whose items are a tuple made of
the song path (to display to the user in case the analysis failed),
and a Result<Analysis>.
Sourcefn analyze_paths_with_cores_with_callback<P: Into<PathBuf>, I: IntoIterator<Item = P>>(
paths: I,
number_cores: NonZeroUsize,
callback: Sender<(PathBuf, AnalysisResult<Analysis>)>,
)
fn analyze_paths_with_cores_with_callback<P: Into<PathBuf>, I: IntoIterator<Item = P>>( paths: I, number_cores: NonZeroUsize, callback: Sender<(PathBuf, AnalysisResult<Analysis>)>, )
Analyze songs in paths, and return the Analysis objects through an
mpsc::IntoIter. number_cores sets the number of cores the analysis
will use, capped by your system’s capacity. Most of the time, you want to
use the simpler analyze_paths_with_callback functions, which autodetects the number
of cores in your system.
Return an iterator, whose items are a tuple made of
the song path (to display to the user in case the analysis failed),
and a Result<Analysis>.
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.