CameraFile

Struct CameraFile 

Source
pub struct CameraFile { /* private fields */ }
Expand description

A file stored on a camera’s storage.

Implementations§

Source§

impl CameraFile

Source

pub fn directory(&self) -> Cow<'_, str>

Returns the directory that the file is stored in.

Source

pub fn basename(&self) -> Cow<'_, str>

Returns the name of the file without the directory.

Examples found in repository?
examples/capture.rs (line 27)
5fn main() {
6    let mut context = match gphoto::Context::new() {
7        Ok(c) => c,
8        Err(err) => panic!("error creating context: {}", err)
9    };
10
11    // open camera
12
13    println!("opening camera ...");
14    let mut camera = match gphoto::Camera::autodetect(&mut context) {
15        Ok(c) => c,
16        Err(err) => panic!("error opening camera: {}", err)
17    };
18    println!(" (done)");
19
20    // capture image
21
22    println!("capturing image ...");
23    let capture = match camera.capture_image(&mut context) {
24        Ok(c) => c,
25        Err(err) => panic!("error capturing image: {}", err)
26    };
27    println!(" (done) {:?}", capture.basename());
28
29    // download file
30
31    let mut file = match gphoto::FileMedia::create(Path::new(capture.basename().as_ref())) {
32        Ok(f) => f,
33        Err(err) => panic!("error saving file: {}", err)
34    };
35
36    println!("downloading ...");
37    if let Err(err) = camera.download(&mut context, &capture, &mut file) {
38        panic!("error downloading file: {}", err);
39    }
40    println!(" (done)");
41}

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.