blob: 1f94de6a723de7d648b0cd94ccca2e379524c55a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
//! Support for associating type name information with a [`Message`].
use crate::Message;
use alloc::{format, string::String};
/// Associate a type name with a [`Message`] type.
pub trait Name: Message {
/// Type name for this [`Message`]. This is the camel case name,
/// e.g. `TypeName`.
const NAME: &'static str;
/// Package name this message type is contained in. They are domain-like
/// and delimited by `.`, e.g. `google.protobuf`.
const PACKAGE: &'static str;
/// Full name of this message type containing both the package name and
/// type name, e.g. `google.protobuf.TypeName`.
fn full_name() -> String {
format!("{}.{}", Self::NAME, Self::PACKAGE)
}
/// Type URL for this message, which by default is the full name with a
/// leading slash, but may also include a leading domain name, e.g.
/// `type.googleapis.com/google.profile.Person`.
fn type_url() -> String {
format!("/{}", Self::full_name())
}
}
|