@@ -58,56 +58,6 @@ pub(crate) fn write_to(file: &mut File, tag: &Tag, file_type: FileType) -> Resul
58
58
write ( file, & mut comments_ref, format, header_packet_count)
59
59
}
60
60
61
- pub ( crate ) fn create_comments (
62
- packet : & mut impl Write ,
63
- count : & mut u32 ,
64
- items : & mut dyn Iterator < Item = ( & str , & str ) > ,
65
- ) -> Result < ( ) > {
66
- for ( k, v) in items {
67
- if v. is_empty ( ) {
68
- continue ;
69
- }
70
-
71
- let comment = format ! ( "{k}={v}" ) ;
72
- let comment_bytes = comment. as_bytes ( ) ;
73
-
74
- let Ok ( bytes_len) = u32:: try_from ( comment_bytes. len ( ) ) else {
75
- err ! ( TooMuchData ) ;
76
- } ;
77
-
78
- * count += 1 ;
79
-
80
- packet. write_u32 :: < LittleEndian > ( bytes_len) ?;
81
- packet. write_all ( comment_bytes) ?;
82
- }
83
-
84
- Ok ( ( ) )
85
- }
86
-
87
- fn create_pictures (
88
- packet : & mut impl Write ,
89
- count : & mut u32 ,
90
- pictures : & mut dyn Iterator < Item = ( & Picture , PictureInformation ) > ,
91
- ) -> Result < ( ) > {
92
- const PICTURE_KEY : & str = "METADATA_BLOCK_PICTURE=" ;
93
-
94
- for ( pic, info) in pictures {
95
- let picture = pic. as_flac_bytes ( info, true ) ;
96
-
97
- let Ok ( bytes_len) = u32:: try_from ( picture. len ( ) + PICTURE_KEY . len ( ) ) else {
98
- err ! ( TooMuchData ) ;
99
- } ;
100
-
101
- * count += 1 ;
102
-
103
- packet. write_u32 :: < LittleEndian > ( bytes_len) ?;
104
- packet. write_all ( PICTURE_KEY . as_bytes ( ) ) ?;
105
- packet. write_all ( & picture) ?;
106
- }
107
-
108
- Ok ( ( ) )
109
- }
110
-
111
61
pub ( super ) fn write < ' a , II , IP > (
112
62
file : & mut File ,
113
63
tag : & mut VorbisCommentsRef < ' a , II , IP > ,
@@ -216,3 +166,53 @@ where
216
166
217
167
Ok ( new_comment_packet. into_inner ( ) )
218
168
}
169
+
170
+ pub ( crate ) fn create_comments (
171
+ packet : & mut impl Write ,
172
+ count : & mut u32 ,
173
+ items : & mut dyn Iterator < Item = ( & str , & str ) > ,
174
+ ) -> Result < ( ) > {
175
+ for ( k, v) in items {
176
+ if v. is_empty ( ) {
177
+ continue ;
178
+ }
179
+
180
+ let comment = format ! ( "{k}={v}" ) ;
181
+ let comment_bytes = comment. as_bytes ( ) ;
182
+
183
+ let Ok ( bytes_len) = u32:: try_from ( comment_bytes. len ( ) ) else {
184
+ err ! ( TooMuchData ) ;
185
+ } ;
186
+
187
+ * count += 1 ;
188
+
189
+ packet. write_u32 :: < LittleEndian > ( bytes_len) ?;
190
+ packet. write_all ( comment_bytes) ?;
191
+ }
192
+
193
+ Ok ( ( ) )
194
+ }
195
+
196
+ fn create_pictures (
197
+ packet : & mut impl Write ,
198
+ count : & mut u32 ,
199
+ pictures : & mut dyn Iterator < Item = ( & Picture , PictureInformation ) > ,
200
+ ) -> Result < ( ) > {
201
+ const PICTURE_KEY : & str = "METADATA_BLOCK_PICTURE=" ;
202
+
203
+ for ( pic, info) in pictures {
204
+ let picture = pic. as_flac_bytes ( info, true ) ;
205
+
206
+ let Ok ( bytes_len) = u32:: try_from ( picture. len ( ) + PICTURE_KEY . len ( ) ) else {
207
+ err ! ( TooMuchData ) ;
208
+ } ;
209
+
210
+ * count += 1 ;
211
+
212
+ packet. write_u32 :: < LittleEndian > ( bytes_len) ?;
213
+ packet. write_all ( PICTURE_KEY . as_bytes ( ) ) ?;
214
+ packet. write_all ( & picture) ?;
215
+ }
216
+
217
+ Ok ( ( ) )
218
+ }
0 commit comments