Skip to content

Commit 515e6ae

Browse files
committed
deprecate field-key in favor of field-name
1 parent 5e5c026 commit 515e6ae

File tree

2 files changed

+41
-27
lines changed

2 files changed

+41
-27
lines changed

Diff for: wit-0.3.0-draft/types.wit

+13-14
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,12 @@ interface types {
107107
/// This type enumerates the different kinds of errors that may occur when
108108
/// setting or appending to a `fields` resource.
109109
variant header-error {
110-
/// This error indicates that a `field-key` or `field-value` was
110+
/// This error indicates that a `field-name` or `field-value` was
111111
/// syntactically invalid when used with an operation that sets headers in a
112112
/// `fields`.
113113
invalid-syntax,
114114

115-
/// This error indicates that a forbidden `field-key` was used when trying
115+
/// This error indicates that a forbidden `field-name` was used when trying
116116
/// to set a header in a `fields`.
117117
forbidden,
118118

@@ -132,11 +132,11 @@ interface types {
132132
immutable,
133133
}
134134

135-
/// Field keys are always strings.
135+
/// Field names are always strings.
136136
///
137137
/// Field keys should always be treated as case insensitive by the `fields`
138138
/// resource for the purposes of equality checking.
139-
type field-key = string;
139+
type field-name = string;
140140

141141
/// Field values should always be ASCII strings. However, in
142142
/// reality, HTTP implementations often have to interpret malformed values,
@@ -154,8 +154,7 @@ interface types {
154154
/// `set`, `append`, and `delete` operations will fail with
155155
/// `header-error.immutable`.
156156
///
157-
/// A `fields` resource should store `field-key`s and `field-value`s in their
158-
/// original casing used to construct or mutate the `fields` resource. The `fields`
157+
/// A `fields` resource should store `field-name`s and `field-value`s in their /// original casing used to construct or mutate the `fields` resource. The `fields`
159158
/// resource should use that original casing when serializing the fields for
160159
/// transport or when returning them from a method.
161160
resource fields {
@@ -181,44 +180,44 @@ interface types {
181180
/// An error result will be returned if any header or value was
182181
/// syntactically invalid, or if a header was forbidden.
183182
from-list: static func(
184-
entries: list<tuple<field-key,field-value>>
183+
entries: list<tuple<field-name,field-value>>
185184
) -> result<fields, header-error>;
186185

187186
/// Get all of the values corresponding to a key. If the key is not present
188187
/// in this `fields`, an empty list is returned. However, if the key is
189188
/// present but empty, this is represented by a list with one or more
190189
/// empty field-values present.
191-
get: func(name: field-key) -> list<field-value>;
190+
get: func(name: field-name) -> list<field-value>;
192191

193192
/// Returns `true` when the key is present in this `fields`. If the key is
194193
/// syntactically invalid, `false` is returned.
195-
has: func(name: field-key) -> bool;
194+
has: func(name: field-name) -> bool;
196195

197196
/// Set all of the values for a key. Clears any existing values for that
198197
/// key, if they have been set.
199198
///
200199
/// Fails with `header-error.immutable` if the `fields` are immutable.
201-
set: func(name: field-key, value: list<field-value>) -> result<_, header-error>;
200+
set: func(name: field-name, value: list<field-value>) -> result<_, header-error>;
202201

203202
/// Delete all values for a key. Does nothing if no values for the key
204203
/// exist.
205204
///
206205
/// Fails with `header-error.immutable` if the `fields` are immutable.
207-
delete: func(name: field-key) -> result<_, header-error>;
206+
delete: func(name: field-name) -> result<_, header-error>;
208207

209208
/// Delete all values for a key. Does nothing if no values for the key
210209
/// exist.
211210
///
212211
/// Returns all values previously corresponding to the key, if any.
213212
///
214213
/// Fails with `header-error.immutable` if the `fields` are immutable.
215-
get-and-delete: func(name: field-key) -> result<list<field-value>, header-error>;
214+
get-and-delete: func(name: field-name) -> result<list<field-value>, header-error>;
216215

217216
/// Append a value for a key. Does not change or delete any existing
218217
/// values for that key.
219218
///
220219
/// Fails with `header-error.immutable` if the `fields` are immutable.
221-
append: func(name: field-key, value: field-value) -> result<_, header-error>;
220+
append: func(name: field-name, value: field-value) -> result<_, header-error>;
222221

223222
/// Retrieve the full set of keys and values in the Fields. Like the
224223
/// constructor, the list represents each key-value pair.
@@ -229,7 +228,7 @@ interface types {
229228
///
230229
/// The keys and values are always returned in the original casing and in
231230
/// the order in which they will be serialized for transport.
232-
entries: func() -> list<tuple<field-key,field-value>>;
231+
entries: func() -> list<tuple<field-name,field-value>>;
233232

234233
/// Make a deep copy of the Fields. Equivalent in behavior to calling the
235234
/// `fields` constructor on the return value of `entries`. The resulting

Diff for: wit/types.wit

+28-13
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,12 @@ interface types {
124124
/// setting or appending to a `fields` resource.
125125
@since(version = 0.2.0)
126126
variant header-error {
127-
/// This error indicates that a `field-key` or `field-value` was
127+
/// This error indicates that a `field-name` or `field-value` was
128128
/// syntactically invalid when used with an operation that sets headers in a
129129
/// `fields`.
130130
invalid-syntax,
131131

132-
/// This error indicates that a forbidden `field-key` was used when trying
132+
/// This error indicates that a forbidden `field-name` was used when trying
133133
/// to set a header in a `fields`.
134134
forbidden,
135135

@@ -138,11 +138,23 @@ interface types {
138138
immutable,
139139
}
140140

141+
/// Field names are always strings.
142+
///
143+
/// Field keys should always be treated as case insensitive by the `fields`
144+
/// resource for the purposes of equality checking.
145+
@since(version = 0.2.1)
146+
type field-name = field-key;
147+
141148
/// Field keys are always strings.
142149
///
143150
/// Field keys should always be treated as case insensitive by the `fields`
144151
/// resource for the purposes of equality checking.
152+
///
153+
/// # Deprecation
154+
///
155+
/// This type has been deprecated in favor of the `field-name` type.
145156
@since(version = 0.2.0)
157+
@deprecate(since = 0.2.1)
146158
type field-key = string;
147159

148160
/// Field values should always be ASCII strings. However, in
@@ -181,63 +193,66 @@ interface types {
181193
/// The tuple is a pair of the field key, represented as a string, and
182194
/// Value, represented as a list of bytes.
183195
///
184-
/// An error result will be returned if any `field-key` or `field-value` is
196+
/// An error result will be returned if any `field-name` or `field-value` is
185197
/// syntactically invalid, or if a field is forbidden.
186198
@since(version = 0.2.0)
187199
from-list: static func(
188-
entries: list<tuple<field-key,field-value>>
200+
entries: list<tuple<field-name,field-value>>
189201
) -> result<fields, header-error>;
190202

191203
/// Get all of the values corresponding to a key. If the key is not present
192204
/// in this `fields` or is syntactically invalid, an empty list is returned.
193205
/// However, if the key is present but empty, this is represented by a list
194206
/// with one or more empty field-values present.
195207
@since(version = 0.2.0)
196-
get: func(name: field-key) -> list<field-value>;
208+
get: func(name: field-name) -> list<field-value>;
197209

198210
/// Returns `true` when the key is present in this `fields`. If the key is
199211
/// syntactically invalid, `false` is returned.
200212
@since(version = 0.2.0)
201-
has: func(name: field-key) -> bool;
213+
has: func(name: field-name) -> bool;
202214

203215
/// Set all of the values for a key. Clears any existing values for that
204216
/// key, if they have been set.
205217
///
206218
/// Fails with `header-error.immutable` if the `fields` are immutable.
207219
///
208-
/// Fails with `header-error.invalid-syntax` if the `field-key` or any of
220+
/// Fails with `header-error.invalid-syntax` if the `field-name` or any of
209221
/// the `field-value`s are syntactically invalid.
210222
@since(version = 0.2.0)
211-
set: func(name: field-key, value: list<field-value>) -> result<_, header-error>;
223+
set: func(name: field-name, value: list<field-value>) -> result<_, header-error>;
212224

213225
/// Delete all values for a key. Does nothing if no values for the key
214226
/// exist.
215227
///
216228
/// Fails with `header-error.immutable` if the `fields` are immutable.
217229
///
218-
/// Fails with `header-error.invalid-syntax` if the `field-key` is
230+
/// Fails with `header-error.invalid-syntax` if the `field-name` is
219231
/// syntactically invalid.
220232
@since(version = 0.2.0)
221-
delete: func(name: field-key) -> result<_, header-error>;
233+
delete: func(name: field-name) -> result<_, header-error>;
222234

223235
/// Append a value for a key. Does not change or delete any existing
224236
/// values for that key.
225237
///
226238
/// Fails with `header-error.immutable` if the `fields` are immutable.
227239
///
228-
/// Fails with `header-error.invalid-syntax` if the `field-key` or
240+
/// Fails with `header-error.invalid-syntax` if the `field-name` or
229241
/// `field-value` are syntactically invalid.
230242
@since(version = 0.2.0)
231-
append: func(name: field-key, value: field-value) -> result<_, header-error>;
243+
append: func(name: field-name, value: field-value) -> result<_, header-error>;
232244

233245
/// Retrieve the full set of keys and values in the Fields. Like the
234246
/// constructor, the list represents each key-value pair.
235247
///
236248
/// The outer list represents each key-value pair in the Fields. Keys
237249
/// which have multiple values are represented by multiple entries in this
238250
/// list with the same key.
251+
///
252+
/// The keys and values are always returned in the original casing and in
253+
/// the order in which they will be serialized for transport.
239254
@since(version = 0.2.0)
240-
entries: func() -> list<tuple<field-key,field-value>>;
255+
entries: func() -> list<tuple<field-name,field-value>>;
241256

242257
/// Make a deep copy of the Fields. Equivalent in behavior to calling the
243258
/// `fields` constructor on the return value of `entries`. The resulting

0 commit comments

Comments
 (0)