mavlink_core/connection/file/config.rs
1use core::fmt::Display;
2use std::path::PathBuf;
3
4/// MAVLink connection address for a file input
5///
6/// # Example
7///
8/// ```ignore
9/// use mavlink::{Connectable, FileConfig};
10/// use std::path::PathBuf;
11///
12/// let config = FileConfig::new(PathBuf::from("/some/path"));
13/// config
14/// .connect::<mavlink::ardupilotmega::MavMessage>()
15/// .unwrap();
16/// ```
17#[derive(Debug, Clone)]
18pub struct FileConfig {
19 pub(crate) address: PathBuf,
20}
21
22impl FileConfig {
23 /// Creates a file input address from a file path string.
24 pub fn new(address: PathBuf) -> Self {
25 Self { address }
26 }
27}
28impl Display for FileConfig {
29 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
30 write!(f, "file:{}", self.address.display())
31 }
32}