|
66 | 66 | use crate::file_header::{
|
67 | 67 | write_file_header, FILE_MAGIC_STRINGTABLE_DATA, FILE_MAGIC_STRINGTABLE_INDEX,
|
68 | 68 | };
|
| 69 | +use crate::file_serialization_sink::FileSerializationSink; |
69 | 70 | use crate::serialization::{Addr, SerializationSink};
|
70 | 71 | use std::sync::Arc;
|
71 | 72 |
|
@@ -135,9 +136,9 @@ const INVALID_STRING_ID: u32 = METADATA_STRING_ID + 1;
|
135 | 136 | pub const FIRST_REGULAR_STRING_ID: u32 = INVALID_STRING_ID + 1;
|
136 | 137 |
|
137 | 138 | /// Write-only version of the string table
|
138 |
| -pub struct StringTableBuilder<S: SerializationSink> { |
139 |
| - data_sink: Arc<S>, |
140 |
| - index_sink: Arc<S>, |
| 139 | +pub struct StringTableBuilder { |
| 140 | + data_sink: Arc<FileSerializationSink>, |
| 141 | + index_sink: Arc<FileSerializationSink>, |
141 | 142 | }
|
142 | 143 |
|
143 | 144 | /// Anything that implements `SerializableString` can be written to a
|
@@ -250,15 +251,18 @@ impl_serializable_string_for_fixed_size!(14);
|
250 | 251 | impl_serializable_string_for_fixed_size!(15);
|
251 | 252 | impl_serializable_string_for_fixed_size!(16);
|
252 | 253 |
|
253 |
| -fn serialize_index_entry<S: SerializationSink>(sink: &S, id: StringId, addr: Addr) { |
| 254 | +fn serialize_index_entry(sink: &FileSerializationSink, id: StringId, addr: Addr) { |
254 | 255 | sink.write_atomic(8, |bytes| {
|
255 | 256 | bytes[0..4].copy_from_slice(&id.0.to_le_bytes());
|
256 | 257 | bytes[4..8].copy_from_slice(&addr.0.to_le_bytes());
|
257 | 258 | });
|
258 | 259 | }
|
259 | 260 |
|
260 |
| -impl<S: SerializationSink> StringTableBuilder<S> { |
261 |
| - pub fn new(data_sink: Arc<S>, index_sink: Arc<S>) -> StringTableBuilder<S> { |
| 261 | +impl StringTableBuilder { |
| 262 | + pub fn new( |
| 263 | + data_sink: Arc<FileSerializationSink>, |
| 264 | + index_sink: Arc<FileSerializationSink>, |
| 265 | + ) -> StringTableBuilder { |
262 | 266 | // The first thing in every file we generate must be the file header.
|
263 | 267 | write_file_header(&*data_sink, FILE_MAGIC_STRINGTABLE_DATA);
|
264 | 268 | write_file_header(&*index_sink, FILE_MAGIC_STRINGTABLE_INDEX);
|
|
0 commit comments