pub struct Location {
pub path: Vec<i32>,
pub span: Vec<i32>,
pub leading_comments: Option<String>,
pub trailing_comments: Option<String>,
pub leading_detached_comments: Vec<String>,
/* private fields */
}Fields§
§path: Vec<i32>Identifies which part of the FileDescriptorProto was defined at this location.
Each element is a field number or an index. They form a path from the root FileDescriptorProto to the place where the definition appears. For example, this path: [ 4, 3, 2, 7, 1 ] refers to: file.message_type(3) // 4, 3
.field(7) // 2, 7
.name() // 1This is because FileDescriptorProto.message_type has field number 4: repeated DescriptorProto message_type = 4; and DescriptorProto.field has field number 2: repeated FieldDescriptorProto field = 2; and FieldDescriptorProto.name has field number 1: optional string name = 1;
Thus, the above path gives the location of a field name. If we removed the last element: [ 4, 3, 2, 7 ] this path refers to the whole field declaration (from the beginning of the label to the terminating semicolon).
Field 1: path
span: Vec<i32>Always has exactly three or four elements: start line, start column, end line (optional, otherwise assumed same as start line), end column. These are packed into a single field for efficiency. Note that line and column numbers are zero-based – typically you will want to add 1 to each before displaying to a user.
Field 2: span
leading_comments: Option<String>If this SourceCodeInfo represents a complete declaration, these are any comments appearing before and after the declaration which appear to be attached to the declaration.
A series of line comments appearing on consecutive lines, with no other tokens appearing on those lines, will be treated as a single comment.
leading_detached_comments will keep paragraphs of comments that appear before (but not connected to) the current element. Each paragraph, separated by empty lines, will be one comment element in the repeated field.
Only the comment content is provided; comment markers (e.g. //) are stripped out. For block comments, leading whitespace and an asterisk will be stripped from the beginning of each line other than the first. Newlines are included in the output.
Examples:
optional int32 foo = 1; // Comment attached to foo. // Comment attached to bar. optional int32 bar = 2;
optional string baz = 3; // Comment attached to baz. // Another line attached to baz.
// Comment attached to moo. // // Another line attached to moo. optional double moo = 4;
// Detached comment for corge. This is not leading or trailing comments // to moo or corge because there are blank lines separating it from // both.
// Detached comment for corge paragraph 2.
optional string corge = 5; /* Block comment attached
* to corge. Leading asterisks
* will be removed. *//* Block comment attached to
* grault. */optional int32 grault = 6;
// ignored detached comments.
Field 3: leading_comments
trailing_comments: Option<String>Field 4: trailing_comments
leading_detached_comments: Vec<String>Field 6: leading_detached_comments
Implementations§
Source§impl Location
impl Location
Sourcepub fn with_leading_comments(self, value: impl Into<String>) -> Self
pub fn with_leading_comments(self, value: impl Into<String>) -> Self
Sets Self::leading_comments to Some(value), consuming and returning self.
Sourcepub fn with_trailing_comments(self, value: impl Into<String>) -> Self
pub fn with_trailing_comments(self, value: impl Into<String>) -> Self
Sets Self::trailing_comments to Some(value), consuming and returning self.
Trait Implementations§
Source§impl DefaultInstance for Location
impl DefaultInstance for Location
Source§fn default_instance() -> &'static Self
fn default_instance() -> &'static Self
Source§impl ExtensionSet for Location
impl ExtensionSet for Location
Source§const PROTO_FQN: &'static str = "google.protobuf.SourceCodeInfo.Location"
const PROTO_FQN: &'static str = "google.protobuf.SourceCodeInfo.Location"
"google.protobuf.FieldOptions". Read moreSource§fn unknown_fields(&self) -> &UnknownFields
fn unknown_fields(&self) -> &UnknownFields
Source§fn unknown_fields_mut(&mut self) -> &mut UnknownFields
fn unknown_fields_mut(&mut self) -> &mut UnknownFields
Source§fn extension<C>(&self, ext: &Extension<C>) -> <C as ExtensionCodec>::Outputwhere
C: ExtensionCodec,
fn extension<C>(&self, ext: &Extension<C>) -> <C as ExtensionCodec>::Outputwhere
C: ExtensionCodec,
Source§fn set_extension<C>(
&mut self,
ext: &Extension<C>,
value: <C as ExtensionCodec>::Value,
)where
C: ExtensionCodec,
fn set_extension<C>(
&mut self,
ext: &Extension<C>,
value: <C as ExtensionCodec>::Value,
)where
C: ExtensionCodec,
Source§fn has_extension<C>(&self, ext: &Extension<C>) -> boolwhere
C: ExtensionCodec,
fn has_extension<C>(&self, ext: &Extension<C>) -> boolwhere
C: ExtensionCodec,
true if any record at the extension’s field number is present. Read moreSource§fn clear_extension<C>(&mut self, ext: &Extension<C>)where
C: ExtensionCodec,
fn clear_extension<C>(&mut self, ext: &Extension<C>)where
C: ExtensionCodec,
Source§fn extension_or_default<C>(
&self,
ext: &Extension<C>,
) -> <C as ExtensionCodec>::Valuewhere
C: ExtensionCodec<Output = Option<<C as ExtensionCodec>::Value>>,
<C as ExtensionCodec>::Value: Default,
fn extension_or_default<C>(
&self,
ext: &Extension<C>,
) -> <C as ExtensionCodec>::Valuewhere
C: ExtensionCodec<Output = Option<<C as ExtensionCodec>::Value>>,
<C as ExtensionCodec>::Value: Default,
[default = ...]
value if absent, or the type’s Default if no proto default was declared. Read moreSource§impl Message for Location
impl Message for Location
Source§fn compute_size(&self, _cache: &mut SizeCache) -> u32
fn compute_size(&self, _cache: &mut SizeCache) -> u32
Returns the total encoded size in bytes.
The result is a u32; the protobuf specification requires all
messages to fit within 2 GiB (2,147,483,647 bytes), so a
compliant message will never overflow this type.
Source§fn write_to(&self, _cache: &mut SizeCache, buf: &mut impl BufMut)
fn write_to(&self, _cache: &mut SizeCache, buf: &mut impl BufMut)
cache (populated by a prior
compute_size call on the same cache). Read moreSource§fn merge_field(
&mut self,
tag: Tag,
buf: &mut impl Buf,
depth: u32,
) -> Result<(), DecodeError>
fn merge_field( &mut self, tag: Tag, buf: &mut impl Buf, depth: u32, ) -> Result<(), DecodeError>
buf. Read moreSource§fn encode(&self, buf: &mut impl BufMut)
fn encode(&self, buf: &mut impl BufMut)
Source§fn encode_with_cache(&self, cache: &mut SizeCache, buf: &mut impl BufMut)
fn encode_with_cache(&self, cache: &mut SizeCache, buf: &mut impl BufMut)
SizeCache, for
reuse across many encodes in a hot loop. Clears the cache first.Source§fn encoded_len(&self) -> u32
fn encoded_len(&self) -> u32
Source§fn encode_length_delimited(&self, buf: &mut impl BufMut)
fn encode_length_delimited(&self, buf: &mut impl BufMut)
Source§fn encode_to_bytes(&self) -> Bytes
fn encode_to_bytes(&self) -> Bytes
bytes::Bytes. Read moreSource§fn decode(buf: &mut impl Buf) -> Result<Self, DecodeError>where
Self: Sized,
fn decode(buf: &mut impl Buf) -> Result<Self, DecodeError>where
Self: Sized,
Source§fn decode_from_slice(data: &[u8]) -> Result<Self, DecodeError>where
Self: Sized,
fn decode_from_slice(data: &[u8]) -> Result<Self, DecodeError>where
Self: Sized,
Source§fn decode_length_delimited(buf: &mut impl Buf) -> Result<Self, DecodeError>where
Self: Sized,
fn decode_length_delimited(buf: &mut impl Buf) -> Result<Self, DecodeError>where
Self: Sized,
Source§fn merge_to_limit(
&mut self,
buf: &mut impl Buf,
depth: u32,
limit: usize,
) -> Result<(), DecodeError>
fn merge_to_limit( &mut self, buf: &mut impl Buf, depth: u32, limit: usize, ) -> Result<(), DecodeError>
Source§fn merge_group(
&mut self,
buf: &mut impl Buf,
depth: u32,
field_number: u32,
) -> Result<(), DecodeError>
fn merge_group( &mut self, buf: &mut impl Buf, depth: u32, field_number: u32, ) -> Result<(), DecodeError>
buf, reading fields until an
EndGroup tag with the given field_number is encountered. Read moreSource§fn merge(&mut self, buf: &mut impl Buf, depth: u32) -> Result<(), DecodeError>
fn merge(&mut self, buf: &mut impl Buf, depth: u32) -> Result<(), DecodeError>
Source§fn merge_from_slice(&mut self, data: &[u8]) -> Result<(), DecodeError>
fn merge_from_slice(&mut self, data: &[u8]) -> Result<(), DecodeError>
Source§fn merge_length_delimited(
&mut self,
buf: &mut impl Buf,
depth: u32,
) -> Result<(), DecodeError>
fn merge_length_delimited( &mut self, buf: &mut impl Buf, depth: u32, ) -> Result<(), DecodeError>
Source§impl MessageName for Location
impl MessageName for Location
Source§const PACKAGE: &'static str = "google.protobuf"
const PACKAGE: &'static str = "google.protobuf"
Source§const NAME: &'static str = "SourceCodeInfo.Location"
const NAME: &'static str = "SourceCodeInfo.Location"
. between nesting levels. Read more