bump dependencies
This commit is contained in:
parent
1103203e64
commit
5c579209f0
@ -8,6 +8,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
|
|
||||||
# [unreleased]
|
# [unreleased]
|
||||||
|
|
||||||
|
- Bumped `thiserror` to v2
|
||||||
|
- Bumped `spacepackets` to v0.13
|
||||||
|
- The source and destination handlers can now be used without the `std` feature and only require
|
||||||
|
the `alloc` feature.
|
||||||
|
|
||||||
# [v0.1.0] 2024-09-11
|
# [v0.1.0] 2024-09-11
|
||||||
|
|
||||||
Initial release
|
Initial release
|
||||||
|
14
Cargo.toml
14
Cargo.toml
@ -18,18 +18,18 @@ name = "cfdp"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
crc = "3"
|
crc = "3"
|
||||||
smallvec = "1"
|
smallvec = "1"
|
||||||
derive-new = "0.6"
|
derive-new = ">=0.6, <=0.7"
|
||||||
|
|
||||||
[dependencies.spacepackets]
|
[dependencies.spacepackets]
|
||||||
version = "0.12"
|
version = "0.13"
|
||||||
default-features = false
|
default-features = false
|
||||||
|
|
||||||
[dependencies.thiserror]
|
[dependencies.thiserror]
|
||||||
version = "1"
|
version = "2"
|
||||||
optional = true
|
default-features = false
|
||||||
|
|
||||||
[dependencies.hashbrown]
|
[dependencies.hashbrown]
|
||||||
version = "0.14"
|
version = ">=0.14, <=0.15"
|
||||||
optional = true
|
optional = true
|
||||||
|
|
||||||
[dependencies.serde]
|
[dependencies.serde]
|
||||||
@ -44,7 +44,7 @@ optional = true
|
|||||||
default = ["std"]
|
default = ["std"]
|
||||||
std = [
|
std = [
|
||||||
"alloc",
|
"alloc",
|
||||||
"thiserror",
|
"thiserror/std",
|
||||||
"spacepackets/std"
|
"spacepackets/std"
|
||||||
]
|
]
|
||||||
alloc = [
|
alloc = [
|
||||||
@ -58,7 +58,7 @@ defmt = ["dep:defmt", "spacepackets/defmt"]
|
|||||||
tempfile = "3"
|
tempfile = "3"
|
||||||
rand = "0.8"
|
rand = "0.8"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
fern = "0.6"
|
fern = "0.7"
|
||||||
chrono = "0.4"
|
chrono = "0.4"
|
||||||
clap = { version = "4", features = ["derive"] }
|
clap = { version = "4", features = ["derive"] }
|
||||||
|
|
||||||
|
13
README.md
13
README.md
@ -14,14 +14,13 @@ The underlying base packet library used to generate the packets to be sent is th
|
|||||||
# Features
|
# Features
|
||||||
|
|
||||||
The goal of this library is to be flexible enough to support the use-cases of both on-board
|
The goal of this library is to be flexible enough to support the use-cases of both on-board
|
||||||
software and of ground software. It has support to make integration on [std] systems as simple
|
software and of ground software. It has support to make integration on `std` systems as simple
|
||||||
as possible, but also has sufficient abstraction to allow for integration on`no_std` environments.
|
as possible, but also has sufficient abstraction to allow for integration on`no_std` environments
|
||||||
Currently, the handlers still require the [std] feature until
|
and can be used on these systems as well as long as the `alloc` feature is activated.
|
||||||
[thiserror supports `error_in_core`](https://github.com/dtolnay/thiserror/pull/304).
|
|
||||||
|
|
||||||
It is recommended to activate the `alloc` feature at the very least to allow using the primary
|
Please note even though the `alloc` feature is required for the core handlers, these components
|
||||||
components provided by this crate. These components will only allocate memory at initialization
|
will only allocate memory at initialization time and thus are still viable for systems where
|
||||||
time and thus are still viable for systems where run-time allocation is prohibited.
|
run-time allocation is prohibited.
|
||||||
|
|
||||||
## Default features
|
## Default features
|
||||||
|
|
||||||
|
@ -55,7 +55,6 @@ use spacepackets::{
|
|||||||
},
|
},
|
||||||
util::{UnsignedByteField, UnsignedEnum},
|
util::{UnsignedByteField, UnsignedEnum},
|
||||||
};
|
};
|
||||||
use thiserror::Error;
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct FileProperties {
|
struct FileProperties {
|
||||||
@ -189,7 +188,7 @@ impl<CheckTimer: CountdownProvider> TransactionParams<CheckTimer> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
pub enum DestError {
|
pub enum DestError {
|
||||||
/// File directive expected, but none specified
|
/// File directive expected, but none specified
|
||||||
#[error("expected file directive")]
|
#[error("expected file directive")]
|
||||||
@ -215,6 +214,7 @@ pub enum DestError {
|
|||||||
#[error("pdu error {0}")]
|
#[error("pdu error {0}")]
|
||||||
Pdu(#[from] PduError),
|
Pdu(#[from] PduError),
|
||||||
#[error("io error {0}")]
|
#[error("io error {0}")]
|
||||||
|
#[cfg(feature = "std")]
|
||||||
Io(#[from] std::io::Error),
|
Io(#[from] std::io::Error),
|
||||||
#[error("file store error {0}")]
|
#[error("file store error {0}")]
|
||||||
Filestore(#[from] FilestoreError),
|
Filestore(#[from] FilestoreError),
|
||||||
|
124
src/filestore.rs
124
src/filestore.rs
@ -1,103 +1,38 @@
|
|||||||
use alloc::string::{String, ToString};
|
|
||||||
use core::fmt::Display;
|
|
||||||
use spacepackets::cfdp::ChecksumType;
|
use spacepackets::cfdp::ChecksumType;
|
||||||
use spacepackets::ByteConversionError;
|
use spacepackets::ByteConversionError;
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
use std::error::Error;
|
|
||||||
use std::path::Path;
|
|
||||||
#[cfg(feature = "std")]
|
|
||||||
pub use std_mod::*;
|
pub use std_mod::*;
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||||
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
pub enum FilestoreError {
|
pub enum FilestoreError {
|
||||||
|
#[error("file does not exist")]
|
||||||
FileDoesNotExist,
|
FileDoesNotExist,
|
||||||
|
#[error("file already exists")]
|
||||||
FileAlreadyExists,
|
FileAlreadyExists,
|
||||||
|
#[error("directory does not exist")]
|
||||||
DirDoesNotExist,
|
DirDoesNotExist,
|
||||||
|
#[error("permission error")]
|
||||||
Permission,
|
Permission,
|
||||||
|
#[error("is not a file")]
|
||||||
IsNotFile,
|
IsNotFile,
|
||||||
|
#[error("is not a directory")]
|
||||||
IsNotDirectory,
|
IsNotDirectory,
|
||||||
ByteConversion(ByteConversionError),
|
#[error("byte conversion: {0}")]
|
||||||
Io {
|
ByteConversion(#[from] ByteConversionError),
|
||||||
raw_errno: Option<i32>,
|
#[error("IO error: {0})")]
|
||||||
string: String,
|
#[cfg(feature = "std")]
|
||||||
},
|
Io(#[from] std::io::Error),
|
||||||
|
#[error("checksum type not implemented: {0:?}")]
|
||||||
ChecksumTypeNotImplemented(ChecksumType),
|
ChecksumTypeNotImplemented(ChecksumType),
|
||||||
|
#[error("utf8 error")]
|
||||||
Utf8Error,
|
Utf8Error,
|
||||||
|
#[error("other error")]
|
||||||
Other,
|
Other,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ByteConversionError> for FilestoreError {
|
|
||||||
fn from(value: ByteConversionError) -> Self {
|
|
||||||
Self::ByteConversion(value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Display for FilestoreError {
|
|
||||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
|
||||||
match self {
|
|
||||||
FilestoreError::FileDoesNotExist => {
|
|
||||||
write!(f, "file does not exist")
|
|
||||||
}
|
|
||||||
FilestoreError::FileAlreadyExists => {
|
|
||||||
write!(f, "file already exists")
|
|
||||||
}
|
|
||||||
FilestoreError::DirDoesNotExist => {
|
|
||||||
write!(f, "directory does not exist")
|
|
||||||
}
|
|
||||||
FilestoreError::Permission => {
|
|
||||||
write!(f, "permission error")
|
|
||||||
}
|
|
||||||
FilestoreError::IsNotFile => {
|
|
||||||
write!(f, "is not a file")
|
|
||||||
}
|
|
||||||
FilestoreError::IsNotDirectory => {
|
|
||||||
write!(f, "is not a directory")
|
|
||||||
}
|
|
||||||
FilestoreError::ByteConversion(e) => {
|
|
||||||
write!(f, "filestore error: {e}")
|
|
||||||
}
|
|
||||||
FilestoreError::Io { raw_errno, string } => {
|
|
||||||
write!(
|
|
||||||
f,
|
|
||||||
"filestore generic IO error with raw errno {:?}: {}",
|
|
||||||
raw_errno, string
|
|
||||||
)
|
|
||||||
}
|
|
||||||
FilestoreError::ChecksumTypeNotImplemented(checksum_type) => {
|
|
||||||
write!(f, "checksum {:?} not implemented", checksum_type)
|
|
||||||
}
|
|
||||||
FilestoreError::Utf8Error => {
|
|
||||||
write!(f, "utf8 error")
|
|
||||||
}
|
|
||||||
FilestoreError::Other => {
|
|
||||||
write!(f, "some filestore error occured")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Error for FilestoreError {
|
|
||||||
fn source(&self) -> Option<&(dyn Error + 'static)> {
|
|
||||||
match self {
|
|
||||||
FilestoreError::ByteConversion(e) => Some(e),
|
|
||||||
_ => None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
|
||||||
impl From<std::io::Error> for FilestoreError {
|
|
||||||
fn from(value: std::io::Error) -> Self {
|
|
||||||
Self::Io {
|
|
||||||
raw_errno: value.raw_os_error(),
|
|
||||||
string: value.to_string(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub trait VirtualFilestore {
|
pub trait VirtualFilestore {
|
||||||
fn create_file(&self, file_path: &str) -> Result<(), FilestoreError>;
|
fn create_file(&self, file_path: &str) -> Result<(), FilestoreError>;
|
||||||
|
|
||||||
@ -122,14 +57,7 @@ pub trait VirtualFilestore {
|
|||||||
|
|
||||||
fn filename_from_full_path(path: &str) -> Option<&str>
|
fn filename_from_full_path(path: &str) -> Option<&str>
|
||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized;
|
||||||
{
|
|
||||||
// Convert the path string to a Path
|
|
||||||
let path = Path::new(path);
|
|
||||||
|
|
||||||
// Extract the file name using the file_name() method
|
|
||||||
path.file_name().and_then(|name| name.to_str())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn is_file(&self, path: &str) -> Result<bool, FilestoreError>;
|
fn is_file(&self, path: &str) -> Result<bool, FilestoreError>;
|
||||||
|
|
||||||
@ -193,7 +121,7 @@ pub mod std_mod {
|
|||||||
use super::*;
|
use super::*;
|
||||||
use std::{
|
use std::{
|
||||||
fs::{self, File, OpenOptions},
|
fs::{self, File, OpenOptions},
|
||||||
io::{BufReader, Read, Seek, SeekFrom, Write},
|
io::{BufReader, Read, Seek, SeekFrom, Write}, path::Path,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
@ -241,10 +169,7 @@ pub mod std_mod {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn create_dir(&self, dir_path: &str) -> Result<(), FilestoreError> {
|
fn create_dir(&self, dir_path: &str) -> Result<(), FilestoreError> {
|
||||||
fs::create_dir(dir_path).map_err(|e| FilestoreError::Io {
|
fs::create_dir(dir_path)?;
|
||||||
raw_errno: e.raw_os_error(),
|
|
||||||
string: e.to_string(),
|
|
||||||
})?;
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -358,6 +283,17 @@ pub mod std_mod {
|
|||||||
_ => Err(FilestoreError::ChecksumTypeNotImplemented(checksum_type)),
|
_ => Err(FilestoreError::ChecksumTypeNotImplemented(checksum_type)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn filename_from_full_path(path: &str) -> Option<&str>
|
||||||
|
where
|
||||||
|
Self: Sized,
|
||||||
|
{
|
||||||
|
// Convert the path string to a Path
|
||||||
|
let path = Path::new(path);
|
||||||
|
|
||||||
|
// Extract the file name using the file_name() method
|
||||||
|
path.file_name().and_then(|name| name.to_str())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl NativeFilestore {
|
impl NativeFilestore {
|
||||||
@ -393,7 +329,7 @@ pub mod std_mod {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use std::{fs, path::Path, println};
|
use std::{fs, path::Path, println, string::ToString};
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use alloc::format;
|
use alloc::format;
|
||||||
|
28
src/lib.rs
28
src/lib.rs
@ -14,11 +14,12 @@
|
|||||||
//! The goal of this library is to be flexible enough to support the use-cases of both on-board
|
//! The goal of this library is to be flexible enough to support the use-cases of both on-board
|
||||||
//! software and of ground software. It has support to make integration on [std] systems as simple
|
//! software and of ground software. It has support to make integration on [std] systems as simple
|
||||||
//! as possible, but also has sufficient abstraction to allow for integration on `no_std`
|
//! as possible, but also has sufficient abstraction to allow for integration on `no_std`
|
||||||
//! environments. Currently, the handlers still require the [std] feature until
|
//! environments and can be used on these systems as well as long as the [alloc] feature is used
|
||||||
//! [thiserror supports `error_in_core`](https://github.com/dtolnay/thiserror/pull/304).
|
//! as well.
|
||||||
//! It is recommended to activate the `alloc` feature at the very least to allow using the primary
|
//!
|
||||||
//! components provided by this crate. These components will only allocate memory at initialization
|
//! Please note even though the [alloc] feature is required for the core handlers, these components
|
||||||
//! time and thus are still viable for systems where run-time allocation is prohibited.
|
//! will only allocate memory at initialization time and thus are still viable for systems where
|
||||||
|
//! run-time allocation is prohibited.
|
||||||
//!
|
//!
|
||||||
//! The core of this library are the [crate::dest::DestinationHandler] and the
|
//! The core of this library are the [crate::dest::DestinationHandler] and the
|
||||||
//! [crate::source::SourceHandler] components which model the CFDP destination and source entity
|
//! [crate::source::SourceHandler] components which model the CFDP destination and source entity
|
||||||
@ -70,12 +71,11 @@ extern crate alloc;
|
|||||||
#[cfg(any(feature = "std", test))]
|
#[cfg(any(feature = "std", test))]
|
||||||
extern crate std;
|
extern crate std;
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
|
||||||
pub mod dest;
|
|
||||||
#[cfg(feature = "alloc")]
|
#[cfg(feature = "alloc")]
|
||||||
|
pub mod dest;
|
||||||
pub mod filestore;
|
pub mod filestore;
|
||||||
pub mod request;
|
pub mod request;
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "alloc")]
|
||||||
pub mod source;
|
pub mod source;
|
||||||
pub mod time;
|
pub mod time;
|
||||||
pub mod user;
|
pub mod user;
|
||||||
@ -83,8 +83,6 @@ pub mod user;
|
|||||||
use crate::time::CountdownProvider;
|
use crate::time::CountdownProvider;
|
||||||
use core::{cell::RefCell, fmt::Debug, hash::Hash};
|
use core::{cell::RefCell, fmt::Debug, hash::Hash};
|
||||||
use crc::{Crc, CRC_32_ISCSI, CRC_32_ISO_HDLC};
|
use crc::{Crc, CRC_32_ISCSI, CRC_32_ISO_HDLC};
|
||||||
#[cfg(feature = "std")]
|
|
||||||
use hashbrown::HashMap;
|
|
||||||
|
|
||||||
#[cfg(feature = "alloc")]
|
#[cfg(feature = "alloc")]
|
||||||
pub use alloc_mod::*;
|
pub use alloc_mod::*;
|
||||||
@ -288,12 +286,12 @@ pub trait RemoteEntityConfigProvider {
|
|||||||
fn remove_config(&mut self, remote_id: u64) -> bool;
|
fn remove_config(&mut self, remote_id: u64) -> bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This is a thin wrapper around a [HashMap] to store remote entity configurations.
|
/// This is a thin wrapper around a [hashbrown::HashMap] to store remote entity configurations.
|
||||||
/// It implements the full [RemoteEntityConfigProvider] trait.
|
/// It implements the full [RemoteEntityConfigProvider] trait.
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "alloc")]
|
||||||
#[derive(Default, Debug)]
|
#[derive(Default, Debug)]
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
pub struct StdRemoteEntityConfigProvider(pub HashMap<u64, RemoteEntityConfig>);
|
pub struct StdRemoteEntityConfigProvider(pub hashbrown::HashMap<u64, RemoteEntityConfig>);
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
impl RemoteEntityConfigProvider for StdRemoteEntityConfigProvider {
|
impl RemoteEntityConfigProvider for StdRemoteEntityConfigProvider {
|
||||||
@ -879,7 +877,7 @@ impl<'raw> PduRawWithInfo<'raw> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if pdu_header.pdu_datafield_len() < 1 {
|
if pdu_header.pdu_datafield_len() < 1 {
|
||||||
return Err(PduError::FormatError);
|
return Err(PduError::Format);
|
||||||
}
|
}
|
||||||
// Route depending on PDU type and directive type if applicable. Retrieve directive type
|
// Route depending on PDU type and directive type if applicable. Retrieve directive type
|
||||||
// from the raw stream for better performance (with sanity and directive code check).
|
// from the raw stream for better performance (with sanity and directive code check).
|
||||||
@ -1548,7 +1546,7 @@ pub(crate) mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn transaction_id_hashable_usable_as_map_key() {
|
fn transaction_id_hashable_usable_as_map_key() {
|
||||||
let mut map = HashMap::new();
|
let mut map = hashbrown::HashMap::new();
|
||||||
let transaction_id_0 = TransactionId::new(
|
let transaction_id_0 = TransactionId::new(
|
||||||
UnsignedByteFieldU8::new(1).into(),
|
UnsignedByteFieldU8::new(1).into(),
|
||||||
UnsignedByteFieldU8::new(2).into(),
|
UnsignedByteFieldU8::new(2).into(),
|
||||||
|
@ -748,25 +748,6 @@ impl<
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn notice_of_completion(&mut self, cfdp_user: &mut impl CfdpUser) {
|
fn notice_of_completion(&mut self, cfdp_user: &mut impl CfdpUser) {
|
||||||
/*
|
|
||||||
def _notice_of_completion(self):
|
|
||||||
if self.cfg.indication_cfg.transaction_finished_indication_required:
|
|
||||||
assert self._params.transaction_id is not None
|
|
||||||
# This happens for unacknowledged file copy operation with no closure.
|
|
||||||
if self._params.finished_params is None:
|
|
||||||
self._params.finished_params = FinishedParams(
|
|
||||||
condition_code=ConditionCode.NO_ERROR,
|
|
||||||
delivery_code=DeliveryCode.DATA_COMPLETE,
|
|
||||||
file_status=FileStatus.FILE_STATUS_UNREPORTED,
|
|
||||||
)
|
|
||||||
indication_params = TransactionFinishedParams(
|
|
||||||
transaction_id=self._params.transaction_id,
|
|
||||||
finished_params=self._params.finished_params,
|
|
||||||
)
|
|
||||||
self.user.transaction_finished_indication(indication_params)
|
|
||||||
# Transaction finished
|
|
||||||
self.reset()
|
|
||||||
*/
|
|
||||||
let tstate = self.tstate.as_ref().unwrap();
|
let tstate = self.tstate.as_ref().unwrap();
|
||||||
if self.local_cfg.indication_cfg.transaction_finished {
|
if self.local_cfg.indication_cfg.transaction_finished {
|
||||||
// The first case happens for unacknowledged file copy operation with no closure.
|
// The first case happens for unacknowledged file copy operation with no closure.
|
||||||
|
Loading…
Reference in New Issue
Block a user