Skip to content

Commit

Permalink
more convenience functions
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianBeilschmidt committed Aug 26, 2022
1 parent 981d7e1 commit c5c12c6
Showing 1 changed file with 33 additions and 3 deletions.
36 changes: 33 additions & 3 deletions src/programs/raster/mdimtranslate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::{
borrow::Borrow,
ffi::CString,
mem::ManuallyDrop,
path::Path,
path::{Path, PathBuf},
ptr::{null, null_mut},
};

Expand Down Expand Up @@ -88,6 +88,36 @@ pub enum MultiDimTranslateDestination {
},
}

impl TryFrom<&str> for MultiDimTranslateDestination {
type Error = GdalError;

fn try_from(path: &str) -> Result<Self> {
Self::path(path)
}
}

impl TryFrom<&Path> for MultiDimTranslateDestination {
type Error = GdalError;

fn try_from(path: &Path) -> Result<Self> {
Self::path(path)
}
}

impl TryFrom<PathBuf> for MultiDimTranslateDestination {
type Error = GdalError;

fn try_from(path: PathBuf) -> Result<Self> {
Self::path(path)
}
}

impl From<Dataset> for MultiDimTranslateDestination {
fn from(dataset: Dataset) -> Self {
Self::dataset(dataset)
}
}

impl Drop for MultiDimTranslateDestination {
fn drop(&mut self) {
match self {
Expand Down Expand Up @@ -215,7 +245,7 @@ mod tests {

let dataset = multi_dim_translate(
&[dataset],
MultiDimTranslateDestination::path(mem_file_path).unwrap(),
mem_file_path.try_into().unwrap(),
Some(
vec![
"-array",
Expand Down Expand Up @@ -246,7 +276,7 @@ mod tests {

let error = multi_dim_translate(
&[output_dataset],
MultiDimTranslateDestination::dataset(dataset),
dataset.into(),
Some(
MultiDimTranslateOptions::new(vec![
"-array",
Expand Down

0 comments on commit c5c12c6

Please sign in to comment.