Skip to content

refactor: remove dead GrpcMethodType::as_reqwest() and as_str() methods - semantically wrong and unused #52

Description

@iamdhakrey

Summary

GrpcMethodType in crates/samvad-models/src/lib.rs exposes as_reqwest() and as_str() methods that map gRPC streaming types to HTTP verbs (GET, POST, PUT, PATCH). This mapping is semantically incorrect — gRPC operates entirely over HTTP/2 and the streaming classification has no mapping to HTTP verbs. The methods are never called in the current codebase.

Location

crates/samvad-models/src/lib.rs · lines 640–658

Code

impl GrpcMethodType {
    pub fn as_reqwest(&self) -> reqwest::Method {
        match self {
            GrpcMethodType::Unary => reqwest::Method::GET,               // wrong
            GrpcMethodType::ClientStreaming => reqwest::Method::POST,    // wrong
            GrpcMethodType::ServerStreaming => reqwest::Method::PUT,     // wrong
            GrpcMethodType::BidirectionalStreaming => reqwest::Method::PATCH, // wrong
        }
    }

    pub fn as_str(&self) -> &'static str {
        match self {
            GrpcMethodType::Unary => "GET",          // wrong
            GrpcMethodType::ClientStreaming => "POST", // wrong
            GrpcMethodType::ServerStreaming => "PUT",  // wrong
            GrpcMethodType::BidirectionalStreaming => "PATCH", // wrong
        }
    }
}

These appear to be copy-paste artefacts from the HttpMethod implementation.

Fix

Remove both as_reqwest() and as_str() from GrpcMethodType. If a display string is needed later, implement Display with proper names ("Unary", "ClientStreaming", etc.) and derive it from the enum variant names or a proper match.

Impact

  • Dead code kept in the public API of samvad-models creates confusion for contributors.
  • A future refactor that accidentally calls .as_reqwest() on a GrpcMethodType will get silently wrong data with no compiler warning.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions