30
31
// String transforms a MessageType into a string
33
>
return string(mt)
34
>
}
35
36
// String tranforms a Type into a string
38
>
return string(pt)
39
>
}
40
41
// Identify is a function that given a protocol message gives the specific
42
// message type of the body and the type of the protocol to which this message
43
// belongs.
45
>
if msg == nil {
46
return TypeUnknown, MessageTypeUnknown, errNilMsg
48
return TypeUnknown, MessageTypeUnknown, errNilBody
49
}
50
52
>
if bodyTypeName == "" {
53
return TypeUnknown, MessageTypeUnknown, errNoName
54
}
55
57
>
lastDot := strings.LastIndex(bodyTypeName, ".")
58
>
if lastDot < 0 {
59
err := fmt.Errorf("%w: no . found in %q", errProtoFmt, bodyTypeName)
60
return TypeUnknown, msgType, err
61
}
63
}
64