Skip to content

Commit

Permalink
fix(prost-build): MSRV for Context
Browse files Browse the repository at this point in the history
  • Loading branch information
mzabaluev committed Nov 19, 2024
1 parent eba3137 commit 75d81e1
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions prost-build/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use prost_types::{

use crate::extern_paths::ExternPaths;
use crate::message_graph::MessageGraph;
use crate::{path, BytesType, Config, MapType, ServiceGenerator};
use crate::{BytesType, Config, MapType, ServiceGenerator};

/// The context providing all the global information needed to generate code.
/// It also provides a more disciplined access to Config
Expand Down Expand Up @@ -49,20 +49,29 @@ impl<'a> Context<'a> {

/// Returns an iterator over the additional attributes configured
/// for the named type.
pub fn type_attributes(&self, fq_type_name: &str) -> path::Iter<'_, String> {
self.config.type_attributes.get(fq_type_name)
pub fn type_attributes(&self, fq_type_name: &str) -> impl Iterator<Item = &str> {
self.config
.type_attributes
.get(fq_type_name)
.map(|s| s.as_str())
}

/// Returns an iterator over the additional attributes configured
/// for the named message.
pub fn message_attributes(&self, fq_message_name: &str) -> path::Iter<'_, String> {
self.config.message_attributes.get(fq_message_name)
pub fn message_attributes(&self, fq_message_name: &str) -> impl Iterator<Item = &str> {
self.config
.message_attributes
.get(fq_message_name)
.map(|s| s.as_str())
}

/// Returns an iterator over the additional attributes configured
/// for the named enum.
pub fn enum_attributes(&self, fq_enum_name: &str) -> path::Iter<'_, String> {
self.config.enum_attributes.get(fq_enum_name)
pub fn enum_attributes(&self, fq_enum_name: &str) -> impl Iterator<Item = &str> {
self.config
.enum_attributes
.get(fq_enum_name)
.map(|s| s.as_str())
}

/// Returns an iterator over the additional attributes configured
Expand All @@ -71,14 +80,15 @@ impl<'a> Context<'a> {
&self,
fq_message_name: &str,
field_name: &str,
) -> path::Iter<'_, String> {
) -> impl Iterator<Item = &str> {
self.config
.field_attributes
.get_field(fq_message_name, field_name)
.map(|s| s.as_str())
}

/// Returns the bytes type configured for the named message field.
pub fn bytes_type(&self, fq_message_name: &str, field_name: &str) -> BytesType {
pub(crate) fn bytes_type(&self, fq_message_name: &str, field_name: &str) -> BytesType {
self.config
.bytes_type
.get_first_field(fq_message_name, field_name)
Expand All @@ -87,7 +97,7 @@ impl<'a> Context<'a> {
}

/// Returns the map type configured for the named message field.
pub fn map_type(&self, fq_message_name: &str, field_name: &str) -> MapType {
pub(crate) fn map_type(&self, fq_message_name: &str, field_name: &str) -> MapType {
self.config
.map_type
.get_first_field(fq_message_name, field_name)
Expand Down

0 comments on commit 75d81e1

Please sign in to comment.