Current section
Files
Jump to
Current section
Files
src/dagger/dsl/search_submatch.gleam
// AUTO-GENERATED BY DAGGER_GLEAM - DO NOT EDIT
import dagger/types.{type Client, type Try} as types
import dagger/interpreter
import dagger/dsl/types as t
import gleam/dynamic/decode
import gleam/list
pub fn search_submatch(id id: t.SearchSubmatch) -> t.SearchSubmatch {
let field = types.Field(name: "loadSearchSubmatchFromID", args: [#("id", types.GDeferred(id.op))], subfields: [])
t.SearchSubmatch(op: types.Pure([field]))
}
/// The match's end offset within the matched lines.
pub fn end(parent: t.SearchSubmatch, client client: Client, then handler: fn(Try(Int)) -> a) -> a {
let field = types.Field(name: "end", args: [], subfields: [])
let op = {
use q <- types.bind(parent.op)
let full_query = list.append(q, [field])
types.Fetch(
fields: full_query,
decoder: decode.dynamic,
next: fn(dyn) {
let path = types.make_path(full_query)
case decode.run(dyn, decode.at(path, decode.int)) {
Ok(val) -> types.Pure(Ok(val))
Error(_) -> types.Pure(Error(types.DecodingError("end")))
}
}
)
}
handler(interpreter.run(op, client))
}
/// A unique identifier for this SearchSubmatch.
pub fn id(parent: t.SearchSubmatch) -> t.SearchSubmatch {
let field = types.Field(name: "id", args: [], subfields: [])
let new_op = {
use q <- types.bind(parent.op)
types.Pure(list.append(q, [field]))
}
t.SearchSubmatch(op: new_op)
}
/// The match's start offset within the matched lines.
pub fn start(parent: t.SearchSubmatch, client client: Client, then handler: fn(Try(Int)) -> a) -> a {
let field = types.Field(name: "start", args: [], subfields: [])
let op = {
use q <- types.bind(parent.op)
let full_query = list.append(q, [field])
types.Fetch(
fields: full_query,
decoder: decode.dynamic,
next: fn(dyn) {
let path = types.make_path(full_query)
case decode.run(dyn, decode.at(path, decode.int)) {
Ok(val) -> types.Pure(Ok(val))
Error(_) -> types.Pure(Error(types.DecodingError("start")))
}
}
)
}
handler(interpreter.run(op, client))
}
/// The matched text.
pub fn text(parent: t.SearchSubmatch, client client: Client, then handler: fn(Try(String)) -> a) -> a {
let field = types.Field(name: "text", args: [], subfields: [])
let op = {
use q <- types.bind(parent.op)
let full_query = list.append(q, [field])
types.Fetch(
fields: full_query,
decoder: decode.dynamic,
next: fn(dyn) {
let path = types.make_path(full_query)
case decode.run(dyn, decode.at(path, decode.string)) {
Ok(val) -> types.Pure(Ok(val))
Error(_) -> types.Pure(Error(types.DecodingError("text")))
}
}
)
}
handler(interpreter.run(op, client))
}