@@ -31,36 +31,36 @@ impl crate::WriteTo for Tag {
31
31
32
32
out. write_all ( NL ) ?;
33
33
if !self . message . is_empty ( ) {
34
- out. write_all ( & self . message ) ?;
34
+ out. write_all ( self . message . as_ref ( ) ) ?;
35
35
}
36
- if let Some ( ref message) = self . pgp_signature {
36
+ if let Some ( message) = & self . pgp_signature {
37
37
out. write_all ( NL ) ?;
38
- out. write_all ( message) ?;
38
+ out. write_all ( message. as_ref ( ) ) ?;
39
39
}
40
40
Ok ( ( ) )
41
41
}
42
42
43
+ fn kind ( & self ) -> Kind {
44
+ Kind :: Tag
45
+ }
46
+
43
47
fn size ( & self ) -> usize {
44
48
b"object" . len ( ) + 1 /* space */ + self . target . kind ( ) . len_in_hex ( ) + 1 /* nl */
45
49
+ b"type" . len ( ) + 1 /* space */ + self . target_kind . as_bytes ( ) . len ( ) + 1 /* nl */
46
50
+ b"tag" . len ( ) + 1 /* space */ + self . name . len ( ) + 1 /* nl */
47
51
+ self
48
- . tagger
49
- . as_ref ( )
50
- . map ( |t| b"tagger" . len ( ) + 1 /* space */ + t. size ( ) + 1 /* nl */ )
51
- . unwrap_or ( 0 )
52
+ . tagger
53
+ . as_ref ( )
54
+ . map ( |t| b"tagger" . len ( ) + 1 /* space */ + t. size ( ) + 1 /* nl */ )
55
+ . unwrap_or ( 0 )
52
56
+ 1 /* nl */ + self . message . len ( )
53
- + self . pgp_signature . as_ref ( ) . map ( |m| 1 /* nl */ + m. len ( ) ) . unwrap_or ( 0 )
54
- }
55
-
56
- fn kind ( & self ) -> Kind {
57
- Kind :: Tag
57
+ + self . pgp_signature . as_ref ( ) . map ( |m| 1 /* nl */ + m. len ( ) ) . unwrap_or ( 0 )
58
58
}
59
59
}
60
60
61
61
impl < ' a > crate :: WriteTo for TagRef < ' a > {
62
62
fn write_to ( & self , mut out : impl io:: Write ) -> io:: Result < ( ) > {
63
- encode:: trusted_header_id ( b"object" , & self . target ( ) , & mut out) ?;
63
+ encode:: trusted_header_field ( b"object" , self . target , & mut out) ?;
64
64
encode:: trusted_header_field ( b"type" , self . target_kind . as_bytes ( ) , & mut out) ?;
65
65
encode:: header_field ( b"tag" , validated_name ( self . name ) ?, & mut out) ?;
66
66
if let Some ( tagger) = & self . tagger {
@@ -78,6 +78,10 @@ impl<'a> crate::WriteTo for TagRef<'a> {
78
78
Ok ( ( ) )
79
79
}
80
80
81
+ fn kind ( & self ) -> Kind {
82
+ Kind :: Tag
83
+ }
84
+
81
85
fn size ( & self ) -> usize {
82
86
b"object" . len ( ) + 1 /* space */ + self . target ( ) . kind ( ) . len_in_hex ( ) + 1 /* nl */
83
87
+ b"type" . len ( ) + 1 /* space */ + self . target_kind . as_bytes ( ) . len ( ) + 1 /* nl */
@@ -90,10 +94,6 @@ impl<'a> crate::WriteTo for TagRef<'a> {
90
94
+ 1 /* nl */ + self . message . len ( )
91
95
+ self . pgp_signature . as_ref ( ) . map ( |m| 1 /* nl */ + m. len ( ) ) . unwrap_or ( 0 )
92
96
}
93
-
94
- fn kind ( & self ) -> Kind {
95
- Kind :: Tag
96
- }
97
97
}
98
98
99
99
fn validated_name ( name : & BStr ) -> Result < & BStr , Error > {
0 commit comments