Skip to content

Commit

Permalink
make fn clearer
Browse files Browse the repository at this point in the history
  • Loading branch information
wilyle committed Nov 3, 2023
1 parent ac8d937 commit c4c9935
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions contracts/src/entity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,22 @@ pub struct EntityEndpoint {
}

impl Entity {
/// Checks to see if this entity supports the requested protocol(s) and operation(s).
/// Checks to see if this entity supports one of the requested protocols and operations.
/// Returns the first endpoint found that contains one of the requested protocols and operations,
/// or `None` if no such endpoint could be found.
///
/// # Arguments
/// - `protocols`: the list of protocols to check
/// - `operations`: the list of operations to check
pub fn is_supported(&self, protocols: &[&str], operations: &[&str]) -> Option<EntityEndpoint> {
/// - `protocols`: the list of protocols which are acceptable
/// - `operations`: the list of operations which are acceptable
pub fn is_supported(
&self,
accepted_protocols: &[&str],
accepted_operations: &[&str],
) -> Option<EntityEndpoint> {
for endpoint in self.endpoints.iter() {
if protocols.contains(&endpoint.protocol.as_str()) {
if accepted_protocols.contains(&endpoint.protocol.as_str()) {
for operation in endpoint.operations.iter() {
if operations.contains(&operation.as_str()) {
if accepted_operations.contains(&operation.as_str()) {
return Some(endpoint.clone());
}
}
Expand Down

0 comments on commit c4c9935

Please sign in to comment.