Skip to content

Commit

Permalink
Deny missing docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex6323 committed Sep 29, 2022
1 parent 8da288a commit 97233da
Show file tree
Hide file tree
Showing 14 changed files with 63 additions and 33 deletions.
2 changes: 1 addition & 1 deletion bee-inx/examples/utxo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ async fn main() -> Result<(), Error> {
let mut unspent_outputs = inx.read_unspent_outputs().await?;

let mut count = 0;
while let Some(_) = unspent_outputs.next().await {
while let Some(_unspent_output) = unspent_outputs.next().await {
count += 1;
}
println!("Read {count} unspent outputs.");
Expand Down
13 changes: 7 additions & 6 deletions bee-inx/src/block/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright 2022 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

/// A module that provides block related INX responses.
pub mod responses;

use futures::stream::{Stream, StreamExt};
Expand All @@ -15,7 +16,7 @@ use crate::{
};

impl Inx {
// TODO
/// Listens to all blocks.
pub async fn listen_to_blocks(&mut self) -> Result<impl Stream<Item = Result<Block, Error>>, Error> {
Ok(self
.client
Expand All @@ -25,7 +26,7 @@ impl Inx {
.map(try_from_inx_type))
}

// TODO
/// Listens to solid blocks.
pub async fn listen_to_solid_blocks(&mut self) -> Result<impl Stream<Item = Result<BlockMetadata, Error>>, Error> {
Ok(self
.client
Expand All @@ -35,7 +36,7 @@ impl Inx {
.map(try_from_inx_type))
}

// TODO
/// Listens to referenced blocks.
pub async fn listen_to_referenced_blocks(
&mut self,
) -> Result<impl Stream<Item = Result<BlockMetadata, Error>>, Error> {
Expand All @@ -47,7 +48,7 @@ impl Inx {
.map(try_from_inx_type))
}

// TODO
/// Requests the block with the given block id.
pub async fn read_block(&mut self, block_id: bee::BlockId) -> Result<Raw<bee::Block>, Error> {
Ok(self
.client
Expand All @@ -58,7 +59,7 @@ impl Inx {
.into())
}

// TODO
/// Requests the metadata of the block with the given block id.
pub async fn read_block_metadata(&mut self, block_id: bee::BlockId) -> Result<BlockMetadata, Error> {
Ok(self
.client
Expand All @@ -68,7 +69,7 @@ impl Inx {
.try_into()?)
}

// TODO
/// Submits a block and returns its corresponding block id.
pub async fn submit_block(&mut self, raw_block: Raw<bee::Block>) -> Result<bee::BlockId, Error> {
Ok(self
.client
Expand Down
1 change: 1 addition & 0 deletions bee-inx/src/block/responses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ impl From<LedgerInclusionState> for inx::LedgerInclusionState {
}
}

/// Whether a block contains a transaction that is either included or conflicting, or contains no transaction at all.
#[allow(missing_docs)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum LedgerInclusionState {
Expand Down
1 change: 1 addition & 0 deletions bee-inx/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use inx::tonic;
use thiserror::Error;

#[allow(missing_docs)]
#[derive(Debug, Error)]
pub enum Error {
#[error(transparent)]
Expand Down
13 changes: 12 additions & 1 deletion bee-inx/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
// Copyright 2022 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

//! Bee compatible INX types and INX node request bindings.
#![deny(missing_docs)]

mod error;

/// A module that provides block related requests..
pub mod block;
/// A module that provides the INX client.
pub mod client;
/// A module that provides milestone related requests.
pub mod milestone;
/// A module that provides node related requests.
pub mod node;
/// A module that provides the [`Raw<T: Packable>`] struct.
pub mod raw;
/// A module that provides UTXO ledger related requests.
pub mod utxo;

pub use self::{block::*, error::Error, milestone::*, node::*, raw::*, utxo::*};

pub mod inx {
pub(crate) mod inx {
pub use ::inx::proto::{
block_metadata::*,
ledger_update::{marker::*, *},
Expand All @@ -36,6 +46,7 @@ pub(crate) mod bee {
pub use bee_block::{protocol::protocol_parameters, rand::output::rand_output};
}

#[allow(missing_docs)]
#[macro_export]
macro_rules! return_err_if_none {
($object:ident.$field:ident) => {
Expand Down
8 changes: 5 additions & 3 deletions bee-inx/src/milestone/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Copyright 2022 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

/// A module that provides milestone related INX requests.
pub mod requests;
/// A module that provides milestone related INX responses.
pub mod responses;

use futures::stream::{Stream, StreamExt};
Expand All @@ -15,7 +17,7 @@ use crate::{
};

impl Inx {
/// TODO
/// Requests a particular milestone.
pub async fn read_milestone(&mut self, request: MilestoneRequest) -> Result<Milestone, Error> {
Ok(self
.client
Expand Down Expand Up @@ -48,7 +50,7 @@ impl Inx {
.map(try_from_inx_type))
}

/// TODO
/// Requests "white flag" data for a milestone.
pub async fn compute_white_flag(&mut self, request: WhiteFlagRequest) -> Result<WhiteFlagResponse, Error> {
Ok(self
.client
Expand All @@ -71,7 +73,7 @@ impl Inx {
.map(try_from_inx_type))
}

/// TODO
/// Reads the past cone metadata of a milestone specified by a [`MilestoneRequest`].
pub async fn read_milestone_cone_metadata(
&mut self,
request: MilestoneRequest,
Expand Down
3 changes: 3 additions & 0 deletions bee-inx/src/milestone/requests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ use std::ops::{Bound, RangeBounds};

use crate::{bee, error, inx};

/// Allows to request a milestone by either its index or its id.
#[allow(missing_docs)]
pub enum MilestoneRequest {
MilestoneIndex(bee::MilestoneIndex),
MilestoneId(bee::MilestoneId),
Expand Down Expand Up @@ -71,6 +73,7 @@ where
}
}

/// Allows to request "white flag" data for a particular milestone.
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct WhiteFlagRequest {
milestone_index: bee::MilestoneIndex,
Expand Down
3 changes: 3 additions & 0 deletions bee-inx/src/milestone/responses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ impl From<Milestone> for inx::Milestone {
}

/// The [`Milestone`] type.
#[allow(missing_docs)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct MilestoneAndProtocolParameters {
pub milestone: Milestone,
Expand Down Expand Up @@ -95,6 +96,8 @@ impl From<MilestoneInfo> for inx::MilestoneInfo {
}
}

/// The response of a corresponding "white flag" request.
#[allow(missing_docs)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct WhiteFlagResponse {
milestone_inclusion_merkle_root: Vec<u8>,
Expand Down
10 changes: 6 additions & 4 deletions bee-inx/src/node/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Copyright 2022 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

/// A module that provides node related INX requests.
pub mod requests;
/// A module that provides node related INX responses.
pub mod responses;

use futures::stream::{Stream, StreamExt};
Expand All @@ -15,13 +17,13 @@ use crate::{
};

impl Inx {
/// TODO
/// Requests the status of the connected node.
pub async fn read_node_status(&mut self) -> Result<NodeStatus, Error> {
NodeStatus::try_from(self.client.read_node_status(inx::NoParams {}).await?.into_inner())
.map_err(Error::InxError)
}

// TODO
/// Listens to node status updates.
pub async fn listen_to_node_status(
&mut self,
request: NodeStatusRequest,
Expand All @@ -34,7 +36,7 @@ impl Inx {
.map(try_from_inx_type))
}

/// TODO
/// Requests the configuration of the connected node.
pub async fn read_node_configuration(&mut self) -> Result<NodeConfiguration, Error> {
NodeConfiguration::try_from(
self.client
Expand All @@ -45,7 +47,7 @@ impl Inx {
.map_err(Error::InxError)
}

/// TODO
/// Requests the protocol parameters of the connected node.
pub async fn read_protocol_parameters(&mut self, request: MilestoneRequest) -> Result<ProtocolParameters, Error> {
Ok(self
.client
Expand Down
3 changes: 2 additions & 1 deletion bee-inx/src/node/requests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

use crate::inx;

/// TODO
/// A request for the node status.
#[allow(missing_docs)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct NodeStatusRequest {
pub cooldown_in_milliseconds: u32,
Expand Down
9 changes: 7 additions & 2 deletions bee-inx/src/node/responses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use crate::{bee, inx, milestone::responses::Milestone, raw::Raw, return_err_if_none};

/// The [`NodeStatus`] type.
/// Represents the [`NodeStatus`] response.
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct NodeStatus {
/// Signals if the node is healthy.
Expand Down Expand Up @@ -64,7 +64,8 @@ impl From<NodeStatus> for inx::NodeStatus {
}
}

/// The [`NodeConfiguration`] type.
/// Represents the [`NodeConfiguration`] response.
#[allow(missing_docs)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct NodeConfiguration {
pub milestone_public_key_count: u32,
Expand Down Expand Up @@ -108,6 +109,7 @@ impl From<NodeConfiguration> for inx::NodeConfiguration {
}

/// The [`BaseToken`] type.
#[allow(missing_docs)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct BaseToken {
pub name: String,
Expand Down Expand Up @@ -144,6 +146,8 @@ impl From<BaseToken> for inx::BaseToken {
}
}

/// Represents a milestone key range.
#[allow(missing_docs)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct MilestoneKeyRange {
pub public_key: Box<[u8]>,
Expand Down Expand Up @@ -171,6 +175,7 @@ impl From<MilestoneKeyRange> for inx::MilestoneKeyRange {
}
}

/// Represents a protocol parameters response.
#[allow(missing_docs)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct ProtocolParameters {
Expand Down
3 changes: 3 additions & 0 deletions bee-inx/src/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,20 @@ pub struct Raw<T: Packable> {
}

impl<T: Packable> Raw<T> {
/// Returns the inner byte data as-is.
#[must_use]
pub fn data(self) -> Vec<u8> {
self.data
}

/// Deserializes the inner byte data into `T`.
pub fn inner(self, visitor: &T::UnpackVisitor) -> Result<T, Error> {
let unpacked = T::unpack_verified(self.data, visitor)
.map_err(|e| bee_block::InxError::InvalidRawBytes(format!("{:?}", e)))?;
Ok(unpacked)
}

/// Deserializes the raw byte data into `T` without verification.
pub fn inner_unverified(self) -> Result<T, Error> {
let unpacked =
T::unpack_unverified(self.data).map_err(|e| bee_block::InxError::InvalidRawBytes(format!("{:?}", e)))?;
Expand Down
11 changes: 6 additions & 5 deletions bee-inx/src/utxo/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright 2022 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

/// A module that provides utxo related INX responses.
pub mod responses;

use futures::{Stream, StreamExt};
Expand All @@ -16,7 +17,7 @@ use crate::{
};

impl Inx {
/// TODO
/// Requests all unspent outputs.
pub async fn read_unspent_outputs(
&mut self,
) -> Result<impl Stream<Item = Result<crate::UnspentOutput, Error>>, Error> {
Expand All @@ -28,7 +29,7 @@ impl Inx {
.map(try_from_inx_type))
}

/// TODO
/// Creates a feed of ledger updates.
pub async fn listen_to_ledger_updates(
&mut self,
request: MilestoneRangeRequest,
Expand All @@ -41,7 +42,7 @@ impl Inx {
.map(try_from_inx_type))
}

/// TODO
/// Creates a feed of treasury updates.
pub async fn listen_to_treasury_updates(
&mut self,
request: MilestoneRangeRequest,
Expand All @@ -54,7 +55,7 @@ impl Inx {
.map(try_from_inx_type))
}

/// TODO
/// Requests an output by its output id.
pub async fn read_output(&mut self, output_id: bee::OutputId) -> Result<OutputResponse, Error> {
Ok(self
.client
Expand All @@ -64,7 +65,7 @@ impl Inx {
.try_into()?)
}

/// TODO
/// Creates a feed of migration receipts.
pub async fn listen_to_migration_receipts(
&mut self,
) -> Result<impl Stream<Item = Result<Raw<bee::MilestoneOption>, Error>>, Error> {
Expand Down
Loading

0 comments on commit 97233da

Please sign in to comment.