pub struct CameraFile { /* private fields */ }Expand description
A file stored on a camera’s storage.
Implementations§
Source§impl CameraFile
impl CameraFile
Sourcepub fn basename(&self) -> Cow<'_, str>
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§
impl Freeze for CameraFile
impl RefUnwindSafe for CameraFile
impl Send for CameraFile
impl Sync for CameraFile
impl Unpin for CameraFile
impl UnwindSafe for CameraFile
Blanket Implementations§
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
Mutably borrows from an owned value. Read more