Skip to content

Commit cd178de

Browse files
authored
Merge pull request parallaxsecond#236 from hug-dev/docs
Add missing_docs lint and missing docs
2 parents d2c0f6a + 29aecbf commit cd178de

File tree

17 files changed

+104
-17
lines changed

17 files changed

+104
-17
lines changed

src/authenticators/direct_authenticator/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use parsec_interface::requests::{ResponseStatus, Result};
1919
use parsec_interface::secrecy::ExposeSecret;
2020
use std::str;
2121

22+
/// Direct authentication authenticator implementation
2223
#[derive(Copy, Clone, Debug)]
2324
pub struct DirectAuthenticator;
2425

src/authenticators/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,12 @@ pub trait Authenticate {
4848
}
4949

5050
impl ApplicationName {
51+
/// Create a new ApplicationName from a String
5152
pub fn new(name: String) -> ApplicationName {
5253
ApplicationName(name)
5354
}
5455

56+
/// Get a reference to the inner string
5557
pub fn get_name(&self) -> &str {
5658
&self.0
5759
}

src/back/backend_handler.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,6 @@ impl BackEndHandler {
5959
pub fn is_capable(&self, request: &Request) -> Result<()> {
6060
let header = &request.header;
6161

62-
// TODO: Add opcode checking here; store supported opcodes as a hashset
63-
// - should we move header field parsing at deserialization?
64-
// TODO: if these two don't match the service should probably panic,
65-
// but I think it's reasonable to assume they do match
6662
if header.provider != self.provider_id {
6763
Err(ResponseStatus::WrongProviderID)
6864
} else if header.content_type != self.content_type {
@@ -257,6 +253,7 @@ pub struct BackEndHandlerBuilder {
257253
}
258254

259255
impl BackEndHandlerBuilder {
256+
/// Create a new BackEndHandler builder
260257
pub fn new() -> BackEndHandlerBuilder {
261258
BackEndHandlerBuilder {
262259
provider: None,
@@ -267,31 +264,37 @@ impl BackEndHandlerBuilder {
267264
}
268265
}
269266

267+
/// Add a provider to the builder
270268
pub fn with_provider(mut self, provider: Arc<dyn Provide + Send + Sync>) -> Self {
271269
self.provider = Some(provider);
272270
self
273271
}
274272

273+
/// Add a converter to the builder
275274
pub fn with_converter(mut self, converter: Box<dyn Convert + Send + Sync>) -> Self {
276275
self.converter = Some(converter);
277276
self
278277
}
279278

279+
/// Set the ID of the BackEndHandler
280280
pub fn with_provider_id(mut self, provider_id: ProviderID) -> Self {
281281
self.provider_id = Some(provider_id);
282282
self
283283
}
284284

285+
/// Set the content type that the BackEndHandler supports
285286
pub fn with_content_type(mut self, content_type: BodyType) -> Self {
286287
self.content_type = Some(content_type);
287288
self
288289
}
289290

291+
/// Set the accept type that the BackEndHandler supports
290292
pub fn with_accept_type(mut self, accept_type: BodyType) -> Self {
291293
self.accept_type = Some(accept_type);
292294
self
293295
}
294296

297+
/// Build into a BackEndHandler
295298
pub fn build(self) -> std::io::Result<BackEndHandler> {
296299
Ok(BackEndHandler {
297300
provider: self

src/back/dispatcher.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,12 @@ pub struct DispatcherBuilder {
6161
}
6262

6363
impl DispatcherBuilder {
64+
/// Create a new Dispatcher builder
6465
pub fn new() -> Self {
6566
DispatcherBuilder { backends: None }
6667
}
6768

69+
/// Add a BackEndHandler with a specific Provider ID to the dispatcher
6870
pub fn with_backend(
6971
mut self,
7072
provider_id: ProviderID,
@@ -77,6 +79,7 @@ impl DispatcherBuilder {
7779
self
7880
}
7981

82+
/// Add multiple BackEndHandler to the dispatcher in one call
8083
pub fn with_backends(mut self, new_backends: HashMap<ProviderID, BackEndHandler>) -> Self {
8184
let mut backends = self.backends.unwrap_or_default();
8285
backends.extend(new_backends);
@@ -85,6 +88,7 @@ impl DispatcherBuilder {
8588
self
8689
}
8790

91+
/// Build the builder into a dispatcher
8892
pub fn build(self) -> Result<Dispatcher> {
8993
Ok(Dispatcher {
9094
backends: self

src/bin/main.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
// Copyright 2019 Contributors to the Parsec project.
22
// SPDX-License-Identifier: Apache-2.0
3+
//! Parsec is the Platform AbstRaction for SECurity, a new open-source initiative to provide a
4+
//! common API to secure services in a platform-agnostic way.
5+
//!
6+
//! Parsec documentation is available
7+
//! [here](https://parallaxsecond.github.io/parsec-book/index.html)
8+
//!
9+
//! Most of Parsec configuration comes from its configuration file.
10+
//! Please check the documentation to find more about configuration
11+
//! [here](https://parallaxsecond.github.io/parsec-book/user_guides/configuration.html)
312
#![deny(
413
nonstandard_style,
514
const_err,
@@ -18,8 +27,7 @@
1827
unused_parens,
1928
while_true,
2029
missing_debug_implementations,
21-
//TODO: activate this!
22-
//missing_docs,
30+
missing_docs,
2331
trivial_casts,
2432
trivial_numeric_casts,
2533
unused_extern_crates,

src/front/domain_socket.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,15 +229,18 @@ pub struct DomainSocketListenerBuilder {
229229
}
230230

231231
impl DomainSocketListenerBuilder {
232+
/// Create a new DomainSocketListener builder
232233
pub fn new() -> Self {
233234
DomainSocketListenerBuilder { timeout: None }
234235
}
235236

237+
/// Add a timeout on the Unix Domain Socket used
236238
pub fn with_timeout(mut self, timeout: Duration) -> Self {
237239
self.timeout = Some(timeout);
238240
self
239241
}
240242

243+
/// Build the builder into the listener
241244
pub fn build(self) -> Result<DomainSocketListener> {
242245
DomainSocketListener::new(self.timeout.ok_or_else(|| {
243246
error!("The listener timeout was not set.");

src/front/front_end.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ pub struct FrontEndHandlerBuilder {
131131
}
132132

133133
impl FrontEndHandlerBuilder {
134+
/// Create a new FrontEndHandler builder
134135
pub fn new() -> Self {
135136
FrontEndHandlerBuilder {
136137
dispatcher: None,
@@ -139,11 +140,13 @@ impl FrontEndHandlerBuilder {
139140
}
140141
}
141142

143+
/// Add a dispatcher to the builder
142144
pub fn with_dispatcher(mut self, dispatcher: Dispatcher) -> Self {
143145
self.dispatcher = Some(dispatcher);
144146
self
145147
}
146148

149+
/// Add an authenticator to the builder
147150
pub fn with_authenticator(
148151
mut self,
149152
auth_type: AuthType,
@@ -163,11 +166,13 @@ impl FrontEndHandlerBuilder {
163166
self
164167
}
165168

169+
/// Set a limit on the maximal body length received
166170
pub fn with_body_len_limit(mut self, body_len_limit: usize) -> Self {
167171
self.body_len_limit = Some(body_len_limit);
168172
self
169173
}
170174

175+
/// Build into a FrontEndHandler
171176
pub fn build(self) -> Result<FrontEndHandler> {
172177
Ok(FrontEndHandler {
173178
dispatcher: self

src/front/listener.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,25 @@ use derivative::Derivative;
99
use serde::Deserialize;
1010
use std::time::Duration;
1111

12-
// This trait is created to allow the iterator returned by incoming to iterate over a trait object
13-
// that implements both Read and Write.
12+
/// This trait is created to allow the iterator returned by incoming to iterate over a trait object
13+
/// that implements both Read and Write.
1414
pub trait ReadWrite: std::io::Read + std::io::Write {}
1515
// Automatically implements ReadWrite for all types that implement Read and Write.
1616
impl<T: std::io::Read + std::io::Write> ReadWrite for T {}
1717

18+
/// Type of the Listener used
1819
#[derive(Copy, Clone, Deserialize, Debug)]
1920
pub enum ListenerType {
21+
/// Listener using Unix Domain Socket
2022
DomainSocket,
2123
}
2224

25+
/// Configuration of the Listener
2326
#[derive(Copy, Clone, Deserialize, Debug)]
2427
pub struct ListenerConfig {
28+
/// Type of the Listener
2529
pub listener_type: ListenerType,
30+
/// Timeout of the Listener before the connection errors out (in milliseconds)
2631
pub timeout: u64,
2732
}
2833

@@ -32,14 +37,14 @@ pub enum ConnectionMetadata {
3237
// TODO: nothing here right now. Metadata types will be added as needed.
3338
}
3439

35-
/// Represents a connection to a single client. Contains a stream, used for communication with the
36-
/// client, and some metadata associated with the connection that might be useful elsewhere (i.e.
37-
/// authentication, etc).
40+
/// Represents a connection to a single client
3841
#[derive(Derivative)]
3942
#[derivative(Debug)]
4043
pub struct Connection {
44+
/// Stream used for communication with the client
4145
#[derivative(Debug = "ignore")]
4246
pub stream: Box<dyn ReadWrite + Send>,
47+
/// Metadata associated with the connection that might be useful elsewhere (i.e. authentication, etc)
4348
pub metadata: Option<ConnectionMetadata>,
4449
}
4550

src/key_info_managers/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,21 @@ use std::fmt;
1515

1616
pub mod on_disk_manager;
1717

18+
/// Type of the KeyInfoManager
1819
#[derive(Copy, Clone, Deserialize, Debug)]
1920
pub enum KeyInfoManagerType {
21+
/// KeyInfoManager storing the mappings on disk
2022
OnDisk,
2123
}
2224

25+
/// KeyInfoManager configuration
2326
#[derive(Deserialize, Debug)]
2427
pub struct KeyInfoManagerConfig {
28+
/// Name of the KeyInfoManager
2529
pub name: String,
30+
/// Type of the KeyInfoManager
2631
pub manager_type: KeyInfoManagerType,
32+
/// Path used to store the mappings
2733
pub store_path: Option<String>,
2834
}
2935

src/key_info_managers/on_disk_manager/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ use std::fs::{DirEntry, File};
2424
use std::io::{Error, ErrorKind, Read, Write};
2525
use std::path::PathBuf;
2626

27+
/// Default path where the mapping files will be stored on disk
2728
pub const DEFAULT_MAPPINGS_PATH: &str = "./mappings";
2829

30+
/// A key info manager storing key triple to key info mapping on files on disk
2931
#[derive(Debug)]
3032
pub struct OnDiskKeyInfoManager {
3133
/// Internal mapping, used for non-modifying operations.
@@ -326,24 +328,28 @@ impl ManageKeyInfo for OnDiskKeyInfoManager {
326328
}
327329
}
328330

331+
/// OnDiskKeyInfoManager builder
329332
#[derive(Debug, Default)]
330333
pub struct OnDiskKeyInfoManagerBuilder {
331334
mappings_dir_path: Option<PathBuf>,
332335
}
333336

334337
impl OnDiskKeyInfoManagerBuilder {
338+
/// Create a new OnDiskKeyInfoManagerBuilder
335339
pub fn new() -> OnDiskKeyInfoManagerBuilder {
336340
OnDiskKeyInfoManagerBuilder {
337341
mappings_dir_path: None,
338342
}
339343
}
340344

345+
/// Add a mappings directory path to the builder
341346
pub fn with_mappings_dir_path(mut self, path: PathBuf) -> OnDiskKeyInfoManagerBuilder {
342347
self.mappings_dir_path = Some(path);
343348

344349
self
345350
}
346351

352+
/// Build into a OnDiskKeyInfoManager
347353
pub fn build(self) -> std::io::Result<OnDiskKeyInfoManager> {
348354
OnDiskKeyInfoManager::new(self.mappings_dir_path.ok_or_else(|| {
349355
error!("Mappings directory path is missing");

0 commit comments

Comments
 (0)