lisette-stdlib 0.2.13

Little language inspired by Rust that compiles to Go
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
// Generated by Lisette bindgen
// Source: log/slog (Go stdlib)
// Go: 1.25.10
// Lisette: 0.2.1

import "go:context"
import "go:io"
import "go:log"
import "go:time"

pub enum Kind: int {
  KindAny = 0,
  KindBool = 1,
  KindDuration = 2,
  KindFloat64 = 3,
  KindGroup = 8,
  KindInt64 = 4,
  KindLogValuer = 9,
  KindString = 5,
  KindTime = 6,
  KindUint64 = 7,
}

pub const KindAny: Kind = 0

pub const KindBool: Kind = 1

pub const KindDuration: Kind = 2

pub const KindFloat64: Kind = 3

pub const KindGroup: Kind = 8

pub const KindInt64: Kind = 4

pub const KindLogValuer: Kind = 9

pub const KindString: Kind = 5

pub const KindTime: Kind = 6

pub const KindUint64: Kind = 7

pub enum Level: int {
  LevelDebug = -4,
  LevelError = 8,
  LevelInfo = 0,
  LevelWarn = 4,
}

pub const LevelDebug: Level = -4

pub const LevelError: Level = 8

pub const LevelInfo: Level = 0

pub const LevelWarn: Level = 4

/// Any returns an Attr for the supplied value.
/// See [AnyValue] for how values are treated.
pub fn Any(key: string, value: Unknown) -> Attr

/// AnyValue returns a [Value] for the supplied value.
/// 
/// If the supplied value is of type Value, it is returned
/// unmodified.
/// 
/// Given a value of one of Go's predeclared string, bool, or
/// (non-complex) numeric types, AnyValue returns a Value of kind
/// [KindString], [KindBool], [KindUint64], [KindInt64], or [KindFloat64].
/// The width of the original numeric type is not preserved.
/// 
/// Given a [time.Time] or [time.Duration] value, AnyValue returns a Value of kind
/// [KindTime] or [KindDuration]. The monotonic time is not preserved.
/// 
/// For nil, or values of all other types, including named types whose
/// underlying type is numeric, AnyValue returns a value of kind [KindAny].
pub fn AnyValue(v: Unknown) -> Value

/// Bool returns an Attr for a bool.
pub fn Bool(key: string, v: bool) -> Attr

/// BoolValue returns a [Value] for a bool.
pub fn BoolValue(v: bool) -> Value

/// Debug calls [Logger.Debug] on the default logger.
pub fn Debug(msg: string, args: VarArgs<Unknown>)

/// DebugContext calls [Logger.DebugContext] on the default logger.
pub fn DebugContext(ctx: context.Context, msg: string, args: VarArgs<Unknown>)

/// Default returns the default [Logger].
pub fn Default() -> Ref<Logger>

/// Duration returns an Attr for a [time.Duration].
pub fn Duration(key: string, v: time.Duration) -> Attr

/// DurationValue returns a [Value] for a [time.Duration].
pub fn DurationValue(v: time.Duration) -> Value

/// Error calls [Logger.Error] on the default logger.
pub fn Error(msg: string, args: VarArgs<Unknown>)

/// ErrorContext calls [Logger.ErrorContext] on the default logger.
pub fn ErrorContext(ctx: context.Context, msg: string, args: VarArgs<Unknown>)

/// Float64 returns an Attr for a floating-point number.
pub fn Float64(key: string, v: float64) -> Attr

/// Float64Value returns a [Value] for a floating-point number.
pub fn Float64Value(v: float64) -> Value

/// Group returns an Attr for a Group [Value].
/// The first argument is the key; the remaining arguments
/// are converted to Attrs as in [Logger.Log].
/// 
/// Use Group to collect several key-value pairs under a single
/// key on a log line, or as the result of LogValue
/// in order to log a single value as multiple Attrs.
pub fn Group(key: string, args: VarArgs<Unknown>) -> Attr

/// GroupAttrs returns an Attr for a Group [Value]
/// consisting of the given Attrs.
/// 
/// GroupAttrs is a more efficient version of [Group]
/// that accepts only [Attr] values.
pub fn GroupAttrs(key: string, attrs: VarArgs<Attr>) -> Attr

/// GroupValue returns a new [Value] for a list of Attrs.
/// The caller must not subsequently mutate the argument slice.
pub fn GroupValue(as_: VarArgs<Attr>) -> Value

/// Info calls [Logger.Info] on the default logger.
pub fn Info(msg: string, args: VarArgs<Unknown>)

/// InfoContext calls [Logger.InfoContext] on the default logger.
pub fn InfoContext(ctx: context.Context, msg: string, args: VarArgs<Unknown>)

/// Int converts an int to an int64 and returns
/// an Attr with that value.
pub fn Int(key: string, value: int) -> Attr

/// Int64 returns an Attr for an int64.
pub fn Int64(key: string, value: int64) -> Attr

/// Int64Value returns a [Value] for an int64.
pub fn Int64Value(v: int64) -> Value

/// IntValue returns a [Value] for an int.
pub fn IntValue(v: int) -> Value

/// Log calls [Logger.Log] on the default logger.
pub fn Log(
  ctx: context.Context,
  level: Level,
  msg: string,
  args: VarArgs<Unknown>,
)

/// LogAttrs calls [Logger.LogAttrs] on the default logger.
pub fn LogAttrs(
  ctx: context.Context,
  level: Level,
  msg: string,
  attrs: VarArgs<Attr>,
)

/// New creates a new Logger with the given non-nil Handler.
pub fn New(h: Handler) -> Ref<Logger>

/// NewJSONHandler creates a [JSONHandler] that writes to w,
/// using the given options.
/// If opts is nil, the default options are used.
pub fn NewJSONHandler(w: io.Writer, opts: Ref<HandlerOptions>) -> Ref<JSONHandler>

/// NewLogLogger returns a new [log.Logger] such that each call to its Output method
/// dispatches a Record to the specified handler. The logger acts as a bridge from
/// the older log API to newer structured logging handlers.
pub fn NewLogLogger(h: Handler, level: Level) -> Ref<log.Logger>

/// NewRecord creates a [Record] from the given arguments.
/// Use [Record.AddAttrs] to add attributes to the Record.
/// 
/// NewRecord is intended for logging APIs that want to support a [Handler] as
/// a backend.
pub fn NewRecord(t: time.Time, level: Level, msg: string, pc: uint) -> Record

/// NewTextHandler creates a [TextHandler] that writes to w,
/// using the given options.
/// If opts is nil, the default options are used.
pub fn NewTextHandler(w: io.Writer, opts: Ref<HandlerOptions>) -> Ref<TextHandler>

/// SetDefault makes l the default [Logger], which is used by
/// the top-level functions [Info], [Debug] and so on.
/// After this call, output from the log package's default Logger
/// (as with [log.Print], etc.) will be logged using l's Handler,
/// at a level controlled by [SetLogLoggerLevel].
pub fn SetDefault(l: Ref<Logger>)

/// SetLogLoggerLevel controls the level for the bridge to the [log] package.
/// 
/// Before [SetDefault] is called, slog top-level logging functions call the default [log.Logger].
/// In that mode, SetLogLoggerLevel sets the minimum level for those calls.
/// By default, the minimum level is Info, so calls to [Debug]
/// (as well as top-level logging calls at lower levels)
/// will not be passed to the log.Logger. After calling
/// 
/// 	slog.SetLogLoggerLevel(slog.LevelDebug)
/// 
/// calls to [Debug] will be passed to the log.Logger.
/// 
/// After [SetDefault] is called, calls to the default [log.Logger] are passed to the
/// slog default handler. In that mode,
/// SetLogLoggerLevel sets the level at which those calls are logged.
/// That is, after calling
/// 
/// 	slog.SetLogLoggerLevel(slog.LevelDebug)
/// 
/// A call to [log.Printf] will result in output at level [LevelDebug].
/// 
/// SetLogLoggerLevel returns the previous value.
pub fn SetLogLoggerLevel(level: Level) -> Level

/// String returns an Attr for a string value.
pub fn String(key: string, value: string) -> Attr

/// StringValue returns a new [Value] for a string.
pub fn StringValue(value: string) -> Value

/// Time returns an Attr for a [time.Time].
/// It discards the monotonic portion.
pub fn Time(key: string, v: time.Time) -> Attr

/// TimeValue returns a [Value] for a [time.Time].
/// It discards the monotonic portion.
pub fn TimeValue(v: time.Time) -> Value

/// Uint64 returns an Attr for a uint64.
pub fn Uint64(key: string, v: uint64) -> Attr

/// Uint64Value returns a [Value] for a uint64.
pub fn Uint64Value(v: uint64) -> Value

/// Warn calls [Logger.Warn] on the default logger.
pub fn Warn(msg: string, args: VarArgs<Unknown>)

/// WarnContext calls [Logger.WarnContext] on the default logger.
pub fn WarnContext(ctx: context.Context, msg: string, args: VarArgs<Unknown>)

/// With calls [Logger.With] on the default logger.
pub fn With(args: VarArgs<Unknown>) -> Ref<Logger>

/// An Attr is a key-value pair.
pub struct Attr {
  pub Key: string,
  pub Value: Value,
}

/// A Handler handles log records produced by a Logger.
/// 
/// A typical handler may print log records to standard error,
/// or write them to a file or database, or perhaps augment them
/// with additional attributes and pass them on to another handler.
/// 
/// Any of the Handler's methods may be called concurrently with itself
/// or with other methods. It is the responsibility of the Handler to
/// manage this concurrency.
/// 
/// Users of the slog package should not invoke Handler methods directly.
/// They should use the methods of [Logger] instead.
/// 
/// Before implementing your own handler, consult https://go.dev/s/slog-handler-guide.
pub interface Handler {
  fn Enabled(ctx: context.Context, level: Level) -> bool
  fn Handle(ctx: context.Context, record: Record) -> Result<(), error>
  fn WithAttrs(attrs: Slice<Attr>) -> Option<Handler>
  fn WithGroup(name: string) -> Option<Handler>
}

/// HandlerOptions are options for a [TextHandler] or [JSONHandler].
/// A zero HandlerOptions consists entirely of default values.
pub struct HandlerOptions {
  pub AddSource: bool,
  pub Level: Option<Leveler>,
  pub ReplaceAttr: Option<fn(Slice<string>, Attr) -> Attr>,
}

/// JSONHandler is a [Handler] that writes Records to an [io.Writer] as
/// line-delimited JSON objects.
pub type JSONHandler

/// A LevelVar is a [Level] variable, to allow a [Handler] level to change
/// dynamically.
/// It implements [Leveler] as well as a Set method,
/// and it is safe for use by multiple goroutines.
/// The zero LevelVar corresponds to [LevelInfo].
pub type LevelVar

/// A Leveler provides a [Level] value.
/// 
/// As Level itself implements Leveler, clients typically supply
/// a Level value wherever a Leveler is needed, such as in [HandlerOptions].
/// Clients who need to vary the level dynamically can provide a more complex
/// Leveler implementation such as *[LevelVar].
pub interface Leveler {
  fn Level() -> Level
}

/// A LogValuer is any Go value that can convert itself into a Value for logging.
/// 
/// This mechanism may be used to defer expensive operations until they are
/// needed, or to expand a single value into a sequence of components.
pub interface LogValuer {
  fn LogValue() -> Value
}

/// A Logger records structured information about each call to its
/// Log, Debug, Info, Warn, and Error methods.
/// For each call, it creates a [Record] and passes it to a [Handler].
/// 
/// To create a new Logger, call [New] or a Logger method
/// that begins "With".
pub type Logger

/// A Record holds information about a log event.
/// Copies of a Record share state.
/// Do not modify a Record after handing out a copy to it.
/// Call [NewRecord] to create a new Record.
/// Use [Record.Clone] to create a copy with no shared state.
pub struct Record {
  pub Time: time.Time,
  pub Message: string,
  pub Level: Level,
  pub PC: uint,
}

/// Source describes the location of a line of source code.
pub struct Source {
  pub Function: string,
  pub File: string,
  pub Line: int,
}

/// TextHandler is a [Handler] that writes Records to an [io.Writer] as a
/// sequence of key=value pairs separated by spaces and followed by a newline.
pub type TextHandler

/// A Value can represent any Go value, but unlike type any,
/// it can represent most small values without an allocation.
/// The zero Value corresponds to nil.
pub type Value

/// Keys for "built-in" attributes.
pub const LevelKey = "level"

/// Keys for "built-in" attributes.
pub const MessageKey = "msg"

/// Keys for "built-in" attributes.
pub const SourceKey = "source"

/// Keys for "built-in" attributes.
pub const TimeKey = "time"

pub var DiscardHandler: Handler

impl Attr {
  /// Equal reports whether a and b have equal keys and values.
  fn Equal(self, b: Attr) -> bool

  fn String(self) -> string
}

impl JSONHandler {
  /// Enabled reports whether the handler handles records at the given level.
  /// The handler ignores records whose level is lower.
  fn Enabled(self: Ref<JSONHandler>, _: context.Context, level: Level) -> bool

  /// Handle formats its argument [Record] as a JSON object on a single line.
  /// 
  /// If the Record's time is zero, the time is omitted.
  /// Otherwise, the key is "time"
  /// and the value is output as with json.Marshal.
  /// 
  /// The level's key is "level" and its value is the result of calling [Level.String].
  /// 
  /// If the AddSource option is set and source information is available,
  /// the key is "source", and the value is a record of type [Source].
  /// 
  /// The message's key is "msg".
  /// 
  /// To modify these or other attributes, or remove them from the output, use
  /// [HandlerOptions.ReplaceAttr].
  /// 
  /// Values are formatted as with an [encoding/json.Encoder] with SetEscapeHTML(false),
  /// with two exceptions.
  /// 
  /// First, an Attr whose Value is of type error is formatted as a string, by
  /// calling its Error method. Only errors in Attrs receive this special treatment,
  /// not errors embedded in structs, slices, maps or other data structures that
  /// are processed by the [encoding/json] package.
  /// 
  /// Second, an encoding failure does not cause Handle to return an error.
  /// Instead, the error message is formatted as a string.
  /// 
  /// Each call to Handle results in a single serialized call to io.Writer.Write.
  fn Handle(self: Ref<JSONHandler>, _: context.Context, r: Record) -> Result<(), error>

  /// WithAttrs returns a new [JSONHandler] whose attributes consists
  /// of h's attributes followed by attrs.
  fn WithAttrs(self: Ref<JSONHandler>, attrs: Slice<Attr>) -> Handler

  fn WithGroup(self: Ref<JSONHandler>, name: string) -> Handler
}

impl Kind {
  fn String(self) -> string
}

impl Level {
  /// AppendText implements [encoding.TextAppender]
  /// by calling [Level.String].
  fn AppendText(self, mut b: Slice<byte>) -> Result<Slice<byte>, error>

  /// Level returns the receiver.
  /// It implements [Leveler].
  fn Level(self) -> Level

  /// MarshalJSON implements [encoding/json.Marshaler]
  /// by quoting the output of [Level.String].
  fn MarshalJSON(self) -> Result<Slice<byte>, error>

  /// MarshalText implements [encoding.TextMarshaler]
  /// by calling [Level.AppendText].
  fn MarshalText(self) -> Result<Slice<byte>, error>

  /// String returns a name for the level.
  /// If the level has a name, then that name
  /// in uppercase is returned.
  /// If the level is between named values, then
  /// an integer is appended to the uppercased name.
  /// Examples:
  /// 
  /// 	LevelWarn.String() => "WARN"
  /// 	(LevelInfo+2).String() => "INFO+2"
  fn String(self) -> string

  /// UnmarshalJSON implements [encoding/json.Unmarshaler]
  /// It accepts any string produced by [Level.MarshalJSON],
  /// ignoring case.
  /// It also accepts numeric offsets that would result in a different string on
  /// output. For example, "Error-8" would marshal as "INFO".
  fn UnmarshalJSON(self: Ref<Level>, data: Slice<byte>) -> Result<(), error>

  /// UnmarshalText implements [encoding.TextUnmarshaler].
  /// It accepts any string produced by [Level.MarshalText],
  /// ignoring case.
  /// It also accepts numeric offsets that would result in a different string on
  /// output. For example, "Error-8" would marshal as "INFO".
  fn UnmarshalText(self: Ref<Level>, data: Slice<byte>) -> Result<(), error>
}

impl LevelVar {
  /// AppendText implements [encoding.TextAppender]
  /// by calling [Level.AppendText].
  fn AppendText(self: Ref<LevelVar>, mut b: Slice<byte>) -> Result<Slice<byte>, error>

  /// Level returns v's level.
  fn Level(self: Ref<LevelVar>) -> Level

  /// MarshalText implements [encoding.TextMarshaler]
  /// by calling [LevelVar.AppendText].
  fn MarshalText(self: Ref<LevelVar>) -> Result<Slice<byte>, error>

  /// Set sets v's level to l.
  fn Set(self: Ref<LevelVar>, l: Level)

  fn String(self: Ref<LevelVar>) -> string

  /// UnmarshalText implements [encoding.TextUnmarshaler]
  /// by calling [Level.UnmarshalText].
  fn UnmarshalText(self: Ref<LevelVar>, data: Slice<byte>) -> Result<(), error>
}

impl Logger {
  /// Debug logs at [LevelDebug].
  fn Debug(self: Ref<Logger>, msg: string, args: VarArgs<Unknown>)

  /// DebugContext logs at [LevelDebug] with the given context.
  fn DebugContext(
    self: Ref<Logger>,
    ctx: context.Context,
    msg: string,
    args: VarArgs<Unknown>,
  )

  /// Enabled reports whether l emits log records at the given context and level.
  fn Enabled(self: Ref<Logger>, ctx: context.Context, level: Level) -> bool

  /// Error logs at [LevelError].
  fn Error(self: Ref<Logger>, msg: string, args: VarArgs<Unknown>)

  /// ErrorContext logs at [LevelError] with the given context.
  fn ErrorContext(
    self: Ref<Logger>,
    ctx: context.Context,
    msg: string,
    args: VarArgs<Unknown>,
  )

  /// Handler returns l's Handler.
  fn Handler(self: Ref<Logger>) -> Handler

  /// Info logs at [LevelInfo].
  fn Info(self: Ref<Logger>, msg: string, args: VarArgs<Unknown>)

  /// InfoContext logs at [LevelInfo] with the given context.
  fn InfoContext(
    self: Ref<Logger>,
    ctx: context.Context,
    msg: string,
    args: VarArgs<Unknown>,
  )

  /// Log emits a log record with the current time and the given level and message.
  /// The Record's Attrs consist of the Logger's attributes followed by
  /// the Attrs specified by args.
  /// 
  /// The attribute arguments are processed as follows:
  ///   - If an argument is an Attr, it is used as is.
  ///   - If an argument is a string and this is not the last argument,
  ///     the following argument is treated as the value and the two are combined
  ///     into an Attr.
  ///   - Otherwise, the argument is treated as a value with key "!BADKEY".
  fn Log(
    self: Ref<Logger>,
    ctx: context.Context,
    level: Level,
    msg: string,
    args: VarArgs<Unknown>,
  )

  /// LogAttrs is a more efficient version of [Logger.Log] that accepts only Attrs.
  fn LogAttrs(
    self: Ref<Logger>,
    ctx: context.Context,
    level: Level,
    msg: string,
    attrs: VarArgs<Attr>,
  )

  /// Warn logs at [LevelWarn].
  fn Warn(self: Ref<Logger>, msg: string, args: VarArgs<Unknown>)

  /// WarnContext logs at [LevelWarn] with the given context.
  fn WarnContext(
    self: Ref<Logger>,
    ctx: context.Context,
    msg: string,
    args: VarArgs<Unknown>,
  )

  /// With returns a Logger that includes the given attributes
  /// in each output operation. Arguments are converted to
  /// attributes as if by [Logger.Log].
  fn With(self: Ref<Logger>, args: VarArgs<Unknown>) -> Ref<Logger>

  /// WithGroup returns a Logger that starts a group, if name is non-empty.
  /// The keys of all attributes added to the Logger will be qualified by the given
  /// name. (How that qualification happens depends on the [Handler.WithGroup]
  /// method of the Logger's Handler.)
  /// 
  /// If name is empty, WithGroup returns the receiver.
  fn WithGroup(self: Ref<Logger>, name: string) -> Ref<Logger>
}

impl Record {
  /// Add converts the args to Attrs as described in [Logger.Log],
  /// then appends the Attrs to the [Record]'s list of Attrs.
  /// It omits empty groups.
  fn Add(self: Ref<Record>, args: VarArgs<Unknown>)

  /// AddAttrs appends the given Attrs to the [Record]'s list of Attrs.
  /// It omits empty groups.
  fn AddAttrs(self: Ref<Record>, attrs: VarArgs<Attr>)

  /// Attrs calls f on each Attr in the [Record].
  /// Iteration stops if f returns false.
  fn Attrs(self, f: fn(Attr) -> bool)

  /// Clone returns a copy of the record with no shared state.
  /// The original record and the clone can both be modified
  /// without interfering with each other.
  fn Clone(self) -> Record

  /// NumAttrs returns the number of attributes in the [Record].
  fn NumAttrs(self) -> int

  /// Source returns a new Source for the log event using r's PC.
  /// If the PC field is zero, meaning the Record was created without the necessary information
  /// or the location is unavailable, then nil is returned.
  fn Source(self) -> Option<Ref<Source>>
}

impl TextHandler {
  /// Enabled reports whether the handler handles records at the given level.
  /// The handler ignores records whose level is lower.
  fn Enabled(self: Ref<TextHandler>, _: context.Context, level: Level) -> bool

  /// Handle formats its argument [Record] as a single line of space-separated
  /// key=value items.
  /// 
  /// If the Record's time is zero, the time is omitted.
  /// Otherwise, the key is "time"
  /// and the value is output in RFC3339 format with millisecond precision.
  /// 
  /// The level's key is "level" and its value is the result of calling [Level.String].
  /// 
  /// If the AddSource option is set and source information is available,
  /// the key is "source" and the value is output as FILE:LINE.
  /// 
  /// The message's key is "msg".
  /// 
  /// To modify these or other attributes, or remove them from the output, use
  /// [HandlerOptions.ReplaceAttr].
  /// 
  /// If a value implements [encoding.TextMarshaler], the result of MarshalText is
  /// written. Otherwise, the result of [fmt.Sprint] is written.
  /// 
  /// Keys and values are quoted with [strconv.Quote] if they contain Unicode space
  /// characters, non-printing characters, '"' or '='.
  /// 
  /// Keys inside groups consist of components (keys or group names) separated by
  /// dots. No further escaping is performed.
  /// Thus there is no way to determine from the key "a.b.c" whether there
  /// are two groups "a" and "b" and a key "c", or a single group "a.b" and a key "c",
  /// or single group "a" and a key "b.c".
  /// If it is necessary to reconstruct the group structure of a key
  /// even in the presence of dots inside components, use
  /// [HandlerOptions.ReplaceAttr] to encode that information in the key.
  /// 
  /// Each call to Handle results in a single serialized call to
  /// io.Writer.Write.
  fn Handle(self: Ref<TextHandler>, _: context.Context, r: Record) -> Result<(), error>

  /// WithAttrs returns a new [TextHandler] whose attributes consists
  /// of h's attributes followed by attrs.
  fn WithAttrs(self: Ref<TextHandler>, attrs: Slice<Attr>) -> Handler

  fn WithGroup(self: Ref<TextHandler>, name: string) -> Handler
}

impl Value {
  /// Any returns v's value as an any.
  fn Any(self) -> Unknown

  /// Bool returns v's value as a bool. It panics
  /// if v is not a bool.
  fn Bool(self) -> bool

  /// Duration returns v's value as a [time.Duration]. It panics
  /// if v is not a time.Duration.
  fn Duration(self) -> time.Duration

  /// Equal reports whether v and w represent the same Go value.
  fn Equal(self, w: Value) -> bool

  /// Float64 returns v's value as a float64. It panics
  /// if v is not a float64.
  fn Float64(self) -> float64

  /// Group returns v's value as a []Attr.
  /// It panics if v's [Kind] is not [KindGroup].
  fn Group(self) -> Slice<Attr>

  /// Int64 returns v's value as an int64. It panics
  /// if v is not a signed integer.
  fn Int64(self) -> int64

  /// Kind returns v's Kind.
  fn Kind(self) -> Kind

  /// LogValuer returns v's value as a LogValuer. It panics
  /// if v is not a LogValuer.
  fn LogValuer(self) -> LogValuer

  /// Resolve repeatedly calls LogValue on v while it implements [LogValuer],
  /// and returns the result.
  /// If v resolves to a group, the group's attributes' values are not recursively
  /// resolved.
  /// If the number of LogValue calls exceeds a threshold, a Value containing an
  /// error is returned.
  /// Resolve's return value is guaranteed not to be of Kind [KindLogValuer].
  fn Resolve(self) -> Value

  /// String returns Value's value as a string, formatted like [fmt.Sprint]. Unlike
  /// the methods Int64, Float64, and so on, which panic if v is of the
  /// wrong kind, String never panics.
  fn String(self) -> string

  /// Time returns v's value as a [time.Time]. It panics
  /// if v is not a time.Time.
  fn Time(self) -> time.Time

  /// Uint64 returns v's value as a uint64. It panics
  /// if v is not an unsigned integer.
  fn Uint64(self) -> uint64
}