mirror of
https://github.com/kristoferssolo/cipher-workshop.git
synced 2026-02-04 06:42:11 +00:00
docs(cipher-factory): document public API types
Add doc comments to OutputFormat, OperationMode enums and their methods. Add crate-level documentation describing the factory's purpose.
This commit is contained in:
@@ -1,3 +1,8 @@
|
||||
//! Cipher factory for creating and configuring block ciphers.
|
||||
//!
|
||||
//! Provides a unified interface for AES and DES encryption/decryption
|
||||
//! with configurable output formats.
|
||||
|
||||
mod algorithm;
|
||||
mod context;
|
||||
mod operation;
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
use std::{convert::Infallible, fmt::Display, str::FromStr};
|
||||
|
||||
/// Cipher operation mode - encrypt or decrypt.
|
||||
#[cfg_attr(feature = "clap", derive(clap::ValueEnum))]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
|
||||
pub enum OperationMode {
|
||||
/// Transform plaintext to ciphertext.
|
||||
#[default]
|
||||
Encrypt,
|
||||
/// Transform ciphertext to plaintext.
|
||||
Decrypt,
|
||||
}
|
||||
|
||||
impl OperationMode {
|
||||
/// Returns the opposite operation mode.
|
||||
#[must_use]
|
||||
pub const fn invert(self) -> Self {
|
||||
match self {
|
||||
|
||||
@@ -2,21 +2,25 @@ use cipher_core::Output;
|
||||
use std::{convert::Infallible, fmt::Display, str::FromStr};
|
||||
use strum::EnumIter;
|
||||
|
||||
/// Output format for displaying cipher results.
|
||||
///
|
||||
/// Controls how decrypted data is presented to the user.
|
||||
#[cfg_attr(feature = "clap", derive(clap::ValueEnum))]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, EnumIter)]
|
||||
pub enum OutputFormat {
|
||||
/// Binary output
|
||||
/// Binary (base-2) representation.
|
||||
Binary,
|
||||
/// Octal output
|
||||
/// Octal (base-8) representation.
|
||||
Octal,
|
||||
/// Decimal output
|
||||
/// Hexadecimal (base-16) representation.
|
||||
#[default]
|
||||
Hex,
|
||||
/// Text output (ASCII)
|
||||
/// ASCII text (attempts UTF-8 decoding).
|
||||
Text,
|
||||
}
|
||||
|
||||
impl OutputFormat {
|
||||
/// Formats the cipher output according to this format.
|
||||
#[must_use]
|
||||
pub fn format(&self, value: &Output) -> String {
|
||||
match self {
|
||||
|
||||
Reference in New Issue
Block a user