feat(fileTransfer): add streaming to fifo #681
feat(fileTransfer): add streaming to fifo #681joshuachp wants to merge 1 commit intoedgehog-device-manager:mainfrom
Conversation
22dd9d6 to
5f3ca8c
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #681 +/- ##
=====================================
Coverage 81.4% 81.4%
=====================================
Files 116 118 +2
Lines 16827 16908 +81
=====================================
+ Hits 13711 13779 +68
- Misses 3116 3129 +13
|
82c8d19 to
cc0e02c
Compare
Signed-off-by: Joshua Chapman <joshua.chapman@secomind.com>
cc0e02c to
107cdce
Compare
| cfg_if::cfg_if! { | ||
| if #[cfg(unix)] { | ||
| pub(crate) type SysPipe = self::unix::MakeFifo; | ||
| } else if #[cfg(windows)] { | ||
| pub(crate) type SysPipe = self::windows::MakeNamedPipe; | ||
| } | ||
| } |
There was a problem hiding this comment.
I think cfg_if! is redundant here, since you already define SysPipe as a type alias for the OS-specific struct, you don't need to re-evaluate the OS.
| cfg_if::cfg_if! { | |
| if #[cfg(unix)] { | |
| pub(crate) type SysPipe = self::unix::MakeFifo; | |
| } else if #[cfg(windows)] { | |
| pub(crate) type SysPipe = self::windows::MakeNamedPipe; | |
| } | |
| } | |
| #[cfg(unix)] | |
| pub(crate) type SysPipe = self::unix::MakeFifo; | |
| #[cfg(windows)] | |
| pub(crate) type SysPipe = self::windows::MakeNamedPipe; |
| impl Streaming<SysPipe> { | ||
| pub(crate) fn with_sys() -> Self { | ||
| cfg_if::cfg_if! { | ||
| if #[cfg(unix)] { | ||
| Self { | ||
| sys: self::unix::MakeFifo::new(), | ||
| } | ||
| } else if #[cfg(windows)] { | ||
| Self { | ||
| sys: self::windows::MakeNamedPipe::new(), | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Since int the change above SysPipe resolves to the correct OS struct at compile time,
you can just call its inherent new() method.
| impl Streaming<SysPipe> { | |
| pub(crate) fn with_sys() -> Self { | |
| cfg_if::cfg_if! { | |
| if #[cfg(unix)] { | |
| Self { | |
| sys: self::unix::MakeFifo::new(), | |
| } | |
| } else if #[cfg(windows)] { | |
| Self { | |
| sys: self::windows::MakeNamedPipe::new(), | |
| } | |
| } | |
| } | |
| } | |
| } | |
| impl Streaming<SysPipe> { | |
| pub(crate) fn with_sys() -> Self { | |
| Self { | |
| sys: SysPipe::new(), | |
| } | |
| } | |
| } |
| pub fn new(dir: PathBuf) -> Self { | ||
| Self { | ||
| storage: FileStorage::new(dir), | ||
| stream: Streaming::with_sys(), |
There was a problem hiding this comment.
nit: I don't have a strong opinion on this, but maybe for a zero-argument constructor, in Rust, it is better to use new() method, or can they have a different types of Streaming here, like sys api etc?
| stream: Streaming::with_sys(), | |
| stream: Streaming::new(), |
No description provided.