Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: Move api::NotBefore into types #188

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 1 addition & 28 deletions core/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ use crate::types::Location;
feature = "filesystem-client"
))]
use crate::types::Message;
use crate::types::PathBuf;
#[cfg(feature = "filesystem-client")]
use crate::types::{DirEntry, UserAttribute};
use crate::types::{DirEntry, NotBefore, PathBuf, UserAttribute};
#[cfg(any(feature = "attestation-client", feature = "crypto-client"))]
use crate::types::{KeyId, Mechanism};
#[cfg(feature = "crypto-client")]
Expand All @@ -51,32 +50,6 @@ mod macros;
//
// At minimum, we don't want to list the indices (may need proc-macro)

#[derive(Clone, Eq, PartialEq, Debug, serde::Serialize, serde::Deserialize)]
pub enum NotBefore {
/// Start iteration at the beginning of the directory
None,
/// Start iteration at an exact match with the provided filename
Filename(PathBuf),
/// Start iteration at the first path that is "after" the provided filename
FilenamePart(PathBuf),
}

impl NotBefore {
pub fn with_filename(value: Option<PathBuf>) -> Self {
match value {
None => Self::None,
Some(p) => Self::Filename(p),
}
}

pub fn with_filename_part(value: Option<PathBuf>) -> Self {
match value {
None => Self::None,
Some(p) => Self::FilenamePart(p),
}
}
}

generate_enums! {

////////////
Expand Down
4 changes: 2 additions & 2 deletions core/src/client/filesystem.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::{ClientResult, PollClient};
use crate::{
api::{reply, request, NotBefore},
types::{Location, Message, PathBuf, UserAttribute},
api::{reply, request},
types::{Location, Message, NotBefore, PathBuf, UserAttribute},
};

/// Read/Write/Delete files, iterate over directories.
Expand Down
27 changes: 27 additions & 0 deletions core/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use serde::{Deserialize, Serialize};
pub use heapless_bytes::Bytes;
pub use littlefs2_core::{DirEntry, Metadata, PathBuf};

#[cfg(feature = "crypto-client")]
use crate::api::{reply, request};
use crate::config::{
MAX_KEY_MATERIAL_LENGTH, MAX_MEDIUM_DATA_LENGTH, MAX_MESSAGE_LENGTH, MAX_SHORT_DATA_LENGTH,
Expand Down Expand Up @@ -386,6 +387,32 @@ impl Default for StorageAttributes {
}
}

#[derive(Clone, Eq, PartialEq, Debug, serde::Serialize, serde::Deserialize)]
pub enum NotBefore {
/// Start iteration at the beginning of the directory
None,
/// Start iteration at an exact match with the provided filename
Filename(PathBuf),
/// Start iteration at the first path that is "after" the provided filename
FilenamePart(PathBuf),
}

impl NotBefore {
pub fn with_filename(value: Option<PathBuf>) -> Self {
match value {
None => Self::None,
Some(p) => Self::Filename(p),
}
}

pub fn with_filename_part(value: Option<PathBuf>) -> Self {
match value {
None => Self::None,
Some(p) => Self::FilenamePart(p),
}
}
}

/// Available client traits.
///
/// This enum does not provide access to the trait features. It is only intended for backends to
Expand Down
2 changes: 2 additions & 0 deletions src/api.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pub use trussed_core::api::*;
pub use trussed_core::types::NotBefore;
sosthene-nitrokey marked this conversation as resolved.
Show resolved Hide resolved
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ generate_macros!();

pub use interchange::Interchange;

pub mod api;
pub mod backend;
pub mod client;
pub mod config;
Expand Down Expand Up @@ -51,7 +52,7 @@ pub use error::Error;
pub use platform::Platform;
pub use service::Service;

pub use trussed_core::{api, block, error, interrupt, syscall, try_syscall};
pub use trussed_core::{block, error, interrupt, syscall, try_syscall};

pub use cbor_smol::cbor_deserialize;
pub use heapless_bytes::Bytes;
Expand Down
Loading