Serialize to `out' which is at least ByteSize() bytes long. Returns bytes written.
| 216 | // Serialize to `out' which is at least ByteSize() bytes long. |
| 217 | // Returns bytes written. |
| 218 | size_t SerializeH2Settings(const H2Settings& in, void* out) { |
| 219 | uint8_t* p = (uint8_t*)out; |
| 220 | if (in.header_table_size != H2Settings::DEFAULT_HEADER_TABLE_SIZE) { |
| 221 | SaveUint16(p, H2_SETTINGS_HEADER_TABLE_SIZE); |
| 222 | SaveUint32(p + 2, in.header_table_size); |
| 223 | p += 6; |
| 224 | } |
| 225 | if (in.enable_push != H2Settings::DEFAULT_ENABLE_PUSH) { |
| 226 | SaveUint16(p, H2_SETTINGS_ENABLE_PUSH); |
| 227 | SaveUint32(p + 2, in.enable_push); |
| 228 | p += 6; |
| 229 | } |
| 230 | if (in.max_concurrent_streams != std::numeric_limits<uint32_t>::max()) { |
| 231 | SaveUint16(p, H2_SETTINGS_MAX_CONCURRENT_STREAMS); |
| 232 | SaveUint32(p + 2, in.max_concurrent_streams); |
| 233 | p += 6; |
| 234 | } |
| 235 | if (in.stream_window_size != H2Settings::DEFAULT_INITIAL_WINDOW_SIZE) { |
| 236 | SaveUint16(p, H2_SETTINGS_STREAM_WINDOW_SIZE); |
| 237 | SaveUint32(p + 2, in.stream_window_size); |
| 238 | p += 6; |
| 239 | } |
| 240 | if (in.max_frame_size != H2Settings::DEFAULT_MAX_FRAME_SIZE) { |
| 241 | SaveUint16(p, H2_SETTINGS_MAX_FRAME_SIZE); |
| 242 | SaveUint32(p + 2, in.max_frame_size); |
| 243 | p += 6; |
| 244 | } |
| 245 | if (in.max_header_list_size != std::numeric_limits<uint32_t>::max()) { |
| 246 | SaveUint16(p, H2_SETTINGS_MAX_HEADER_LIST_SIZE); |
| 247 | SaveUint32(p + 2, in.max_header_list_size); |
| 248 | p += 6; |
| 249 | } |
| 250 | return static_cast<size_t>(p - (uint8_t*)out); |
| 251 | } |
| 252 | |
| 253 | static size_t SerializeH2SettingsFrameAndWU(const H2Settings& in, void* out) { |
| 254 | uint8_t* p = (uint8_t*)out; |