diff --git a/packages/typespec-rust/CHANGELOG.md b/packages/typespec-rust/CHANGELOG.md index ddefaaa94..d59752e92 100644 --- a/packages/typespec-rust/CHANGELOG.md +++ b/packages/typespec-rust/CHANGELOG.md @@ -1,6 +1,13 @@ # Release History -## 0.31.1 (unreleased) +## 0.32.0 (2025-12-11) + +### Breaking Changes + +**Note this version is incompatible with earlier versions of `azure_core`** + +* Replaced `Pager::from_callback` with `Pager::new`. +* Updated generic type parameters to `Pager<>` and `PagerOptions<>` type as required by the paging strategy. ### Features Added diff --git a/packages/typespec-rust/package.json b/packages/typespec-rust/package.json index b166cce87..c8ad7e49c 100644 --- a/packages/typespec-rust/package.json +++ b/packages/typespec-rust/package.json @@ -1,6 +1,6 @@ { "name": "@azure-tools/typespec-rust", - "version": "0.31.1", + "version": "0.32.0", "description": "TypeSpec emitter for Rust SDKs", "type": "module", "packageManager": "pnpm@10.10.0", diff --git a/packages/typespec-rust/src/codegen/clients.ts b/packages/typespec-rust/src/codegen/clients.ts index 0d05cb147..b1d3af0ce 100644 --- a/packages/typespec-rust/src/codegen/clients.ts +++ b/packages/typespec-rust/src/codegen/clients.ts @@ -349,7 +349,7 @@ function getMethodOptions(crate: rust.Crate): helpers.Module { body += `${indent.push().get()}${method.options.type.name} {\n`; indent.push(); for (const field of method.options.type.fields) { - if (field.type.kind === 'external' && (field.type.name === 'ClientMethodOptions' || field.type.name === 'PagerOptions' || field.type.name === 'PollerOptions')) { + if (field.type.kind === 'clientMethodOptions' || field.type.kind === 'pagerOptions' || field.type.kind === 'pollerOptions') { body += `${indent.get()}${field.name}: ${field.type.name} {\n`; body += `${indent.push().get()}context: self.${field.name}.context.into_owned(),\n`; body += `${indent.get()}..self.${field.name}\n`; @@ -1267,7 +1267,7 @@ function getPageableMethodBody(indent: helpers.indentation, use: Use, client: ru switch (method.strategy.kind) { case 'continuationToken': { const reqTokenParam = method.strategy.requestToken.name; - body += `${indent.get()}Ok(${method.returns.type.name}::from_callback(move |${reqTokenParam}: PagerState, pager_options| {\n`; + body += `${indent.get()}Ok(${method.returns.type.name}::new(move |${reqTokenParam}: PagerState, pager_options| {\n`; body += `${indent.push().get()}let ${method.strategy.requestToken.kind === 'queryScalar' ? 'mut ' : ''}url = first_url.clone();\n`; if (method.strategy.requestToken.kind === 'queryScalar') { // if the url already contains the token query param, @@ -1290,7 +1290,7 @@ function getPageableMethodBody(indent: helpers.indentation, use: Use, client: ru case 'nextLink': { const nextLinkName = method.strategy.nextLinkPath[method.strategy.nextLinkPath.length - 1].name; const reinjectedParams = method.strategy.reinjectedParams; - body += `${indent.get()}Ok(${method.returns.type.name}::from_callback(move |${nextLinkName}: PagerState, pager_options| {\n`; + body += `${indent.get()}Ok(${method.returns.type.name}::new(move |${nextLinkName}: PagerState, pager_options| {\n`; body += `${indent.push().get()}let url = ` + helpers.buildMatch(indent, nextLinkName, [{ pattern: `PagerState::More(${nextLinkName})`, body: (indent) => { @@ -1336,7 +1336,7 @@ function getPageableMethodBody(indent: helpers.indentation, use: Use, client: ru } } else { // no next link when there's no strategy - body += `${indent.get()}Ok(Pager::from_callback(move |_: PagerState, pager_options| {\n`; + body += `${indent.get()}Ok(${method.returns.type.name}::new(move |_: PagerState, pager_options| {\n`; indent.push(); cloneUrl = true; srcUrlVar = urlVar; @@ -1357,7 +1357,7 @@ function getPageableMethodBody(indent: helpers.indentation, use: Use, client: ru const requestResult = constructRequest(indent, use, method, paramGroups, true, srcUrlVar, cloneUrl); body += requestResult.content; body += `${indent.get()}let pipeline = pipeline.clone();\n`; - body += `${indent.get()}async move {\n`; + body += `${indent.get()}Box::pin(async move {\n`; body += `${indent.push().get()}let rsp${rspType} = pipeline.send(&pager_options.context, &mut ${requestResult.requestVarName}, ${getPipelineOptions(indent, use, method)}).await?${rspInto};\n`; // check if we need to extract the next link field from the response model @@ -1436,9 +1436,9 @@ function getPageableMethodBody(indent: helpers.indentation, use: Use, client: ru body += `${indent.get()}Ok(PagerResult::Done { response: rsp.into() })\n`; } - body += `${indent.pop().get()}}\n`; // end async move - body += `${indent.get()}},\n${indent.get()}Some(options.method_options),\n`; // end move - body += `${indent.pop().get()}))`; // end Ok/Pager::from_callback + body += `${indent.pop().get()}})\n`; // end Box::pin(async move { + body += `${indent.get()}},\n${indent.get()}Some(options.method_options),\n`; // end move { + body += `${indent.pop().get()}))`; // end Ok(Pager::new( return body; } diff --git a/packages/typespec-rust/src/codegen/helpers.ts b/packages/typespec-rust/src/codegen/helpers.ts index 3a6808c1d..47b64fd2f 100644 --- a/packages/typespec-rust/src/codegen/helpers.ts +++ b/packages/typespec-rust/src/codegen/helpers.ts @@ -164,6 +164,9 @@ export function getTypeDeclaration(type: rust.Client | rust.Payload | rust.Respo case 'decimal': case 'marker': return type.name; + case 'clientMethodOptions': + case 'pollerOptions': + return `${type.name}${getGenericLifetimeAnnotation(type.lifetime)}`; case 'encodedBytes': return type.slice ? '[u8]' : 'Vec'; case 'enumValue': @@ -178,9 +181,22 @@ export function getTypeDeclaration(type: rust.Client | rust.Payload | rust.Respo return getTypeDeclaration(type.valueKind); case 'option': return `Option<${getTypeDeclaration(type.type, withLifetime)}>`; - case 'pager': + case 'pager': { + let formatParam = ''; + let continuationParam = ''; + // we need a third generic type param when the continuation isn't a next link + if (type.continuation !== 'nextLink') { + formatParam = `, ${type.type.format}`; + continuationParam = ', String'; + } else if (type.type.format !== 'JsonFormat') { + formatParam = `, ${type.type.format}`; + } // we explicitly omit the Response from the type decl - return `Pager<${getTypeDeclaration(type.type.content, withLifetime)}${type.type.format !== 'JsonFormat' ? `, ${type.type.format}` : ''}>`; + return `Pager<${getTypeDeclaration(type.type.content, withLifetime)}${formatParam}${continuationParam}>`; + } + case 'pagerOptions': + // for continuation tokens we need an extra generic type parameter + return `${type.name}<${type.lifetime.name}${type.continuation === 'nextLink' ? '' : ', String'}>`; case 'poller': // we explicitly omit the Response from the type decl return `Poller<${getTypeDeclaration(type.type.content, withLifetime)}>`; diff --git a/packages/typespec-rust/src/codegen/use.ts b/packages/typespec-rust/src/codegen/use.ts index 4d741760e..a94a1e3e1 100644 --- a/packages/typespec-rust/src/codegen/use.ts +++ b/packages/typespec-rust/src/codegen/use.ts @@ -116,6 +116,14 @@ export class Use { case 'Vec': this.addForType(type.type); break; + case 'pager': + if (type.continuation !== 'nextLink') { + // continuation token strategy will require the C + // type param in Pager<'a, F, C> so we must bring + // the format type into scope + this.add('azure_core::http', type.type.format); + } + break; case 'payload': this.addForType(type.type); break; diff --git a/packages/typespec-rust/src/codemodel/types.ts b/packages/typespec-rust/src/codemodel/types.ts index c95ae9886..5ca460a5f 100644 --- a/packages/typespec-rust/src/codemodel/types.ts +++ b/packages/typespec-rust/src/codemodel/types.ts @@ -15,7 +15,7 @@ export interface Docs { } /** SdkType defines types used in generated code but do not directly participate in serde */ -export type SdkType = Arc | AsyncResponse | Box | ImplTrait | MarkerType | Option | Pager | Poller | RawResponse | RequestContent | Response | Result | Struct | TokenCredential | Unit; +export type SdkType = Arc | AsyncResponse | Box | ClientMethodOptions | ImplTrait | MarkerType | Option | Pager | PagerOptions | Poller | PollerOptions | RawResponse | RequestContent | Response | Result | Struct | TokenCredential | Unit; /** WireType defines types that go across the wire */ export type WireType = Bytes | Decimal | DiscriminatedUnion | EncodedBytes | Enum | EnumValue | Etag | ExternalType | HashMap | JsonValue | Literal | Model | OffsetDateTime | RefBase | SafeInt | Scalar | Slice | StringSlice | StringType | Url | Vector; @@ -58,6 +58,14 @@ export interface Bytes extends External { kind: 'bytes'; } +/** ClientMethodOptions is a ClientMethodOptions<'a> from azure_core */ +export interface ClientMethodOptions extends External { + kind: 'clientMethodOptions'; + + /** the lifetime annotation */ + lifetime: Lifetime; +} + /** Decimal is a rust_decimal::Decimal type */ export interface Decimal extends External { kind: 'decimal'; @@ -330,6 +338,23 @@ export interface Pager extends External { /** the model containing the page of items */ type: Response>; + + /** the type of continuation used by the pager */ + continuation: PagerContinuationKind; +} + +/** PagerContinuationKind contains the kinds of paging continuations */ +export type PagerContinuationKind = 'token' | 'nextLink'; + +/** PagerOptions is a PagerOptions<'a, C> from azure_core */ +export interface PagerOptions extends External { + kind: 'pagerOptions'; + + /** the lifetime annotation */ + lifetime: Lifetime; + + /** the type of continuation used by the pager */ + continuation: PagerContinuationKind; } /** Poller is a Poller from azure_core */ @@ -343,6 +368,14 @@ export interface Poller extends External { type: Response>; } +/** PollerOptions is a PollerOptions<'a> from azure_core */ +export interface PollerOptions extends External { + kind: 'pollerOptions'; + + /** the lifetime annotation */ + lifetime: Lifetime; +} + /** PayloadFormat indicates the wire format for request bodies */ export type PayloadFormat = 'json' | 'xml'; @@ -657,6 +690,14 @@ export class Bytes extends External implements Bytes { } } +export class ClientMethodOptions extends External implements ClientMethodOptions { + constructor(crate: Crate, lifetime: Lifetime) { + super(crate, 'ClientMethodOptions', 'azure_core::http'); + this.kind = 'clientMethodOptions'; + this.lifetime = lifetime; + } +} + export class Decimal extends External implements Decimal { constructor(crate: Crate, stringEncoding: boolean) { super(crate, 'Decimal', 'rust_decimal', !stringEncoding ? ['serde-with-float'] : undefined); @@ -814,10 +855,20 @@ export class Option implements Option { } export class Pager extends External implements Pager { - constructor(crate: Crate, type: Response>) { + constructor(crate: Crate, type: Response>, continuation: PagerContinuationKind) { super(crate, 'Pager', 'azure_core::http'); this.kind = 'pager'; this.type = type; + this.continuation = continuation; + } +} + +export class PagerOptions extends External implements PagerOptions { + constructor(crate: Crate, lifetime: Lifetime, continuation: PagerContinuationKind) { + super(crate, 'PagerOptions', 'azure_core::http::pager'); + this.kind = 'pagerOptions'; + this.lifetime = lifetime; + this.continuation = continuation; } } @@ -829,6 +880,14 @@ export class Poller extends External implements Poller { } } +export class PollerOptions extends External implements PollerOptions { + constructor(crate: Crate, lifetime: Lifetime) { + super(crate, 'PollerOptions', 'azure_core::http::poller'); + this.kind = 'pollerOptions'; + this.lifetime = lifetime; + } +} + export class Payload implements Payload { constructor(type: T, format: PayloadFormat) { this.kind = 'payload'; diff --git a/packages/typespec-rust/src/tcgcadapter/adapter.ts b/packages/typespec-rust/src/tcgcadapter/adapter.ts index 2ee639ff7..c3f1d7869 100644 --- a/packages/typespec-rust/src/tcgcadapter/adapter.ts +++ b/packages/typespec-rust/src/tcgcadapter/adapter.ts @@ -1309,19 +1309,19 @@ export class Adapter { methodOptionsStruct.lifetime = optionsLifetime; methodOptionsStruct.docs.summary = `Options to be passed to ${this.asDocLink(`${rustClient.name}::${methodName}()`, `crate::generated::clients::${rustClient.name}::${methodName}()`)}`; - let clientMethodOptions: rust.ExternalType; + let clientMethodOptions: rust.ClientMethodOptions | rust.PagerOptions | rust.PollerOptions; switch (method.kind) { case 'paging': - clientMethodOptions = new rust.ExternalType(this.crate, 'PagerOptions', 'azure_core::http::pager'); + // default to nextLink. will update it as required when we have that info + clientMethodOptions = new rust.PagerOptions(this.crate, optionsLifetime, 'nextLink'); break; case 'lro': - clientMethodOptions = new rust.ExternalType(this.crate, 'PollerOptions', 'azure_core::http::poller'); + clientMethodOptions = new rust.PollerOptions(this.crate, optionsLifetime); break; default: - clientMethodOptions = new rust.ExternalType(this.crate, 'ClientMethodOptions', 'azure_core::http'); + clientMethodOptions = new rust.ClientMethodOptions(this.crate, optionsLifetime); } - clientMethodOptions.lifetime = optionsLifetime; const methodOptionsField = new rust.StructField('method_options', 'pub', clientMethodOptions); methodOptionsField.docs.summary = 'Allows customization of the method call.'; methodOptionsStruct.fields.push(methodOptionsField); @@ -1606,7 +1606,8 @@ export class Adapter { } this.crate.addDependency(new rust.CrateDependency('async-trait')); - rustMethod.returns = new rust.Result(this.crate, new rust.Pager(this.crate, new rust.Response(this.crate, synthesizedModel, responseFormat))); + // default to nextLink. will update it as required when we have that info + rustMethod.returns = new rust.Result(this.crate, new rust.Pager(this.crate, new rust.Response(this.crate, synthesizedModel, responseFormat), 'nextLink')); } else if (method.kind === 'lro') { const format = responseFormat === 'NoFormat' ? 'JsonFormat' : responseFormat @@ -1689,6 +1690,14 @@ export class Adapter { pageableMethod.strategy = this.adaptPageableMethodStrategy(method, paramsMap, responseHeadersMap); if (pageableMethod.strategy?.kind === 'nextLink') { pageableMethod.strategy.reinjectedParams = this.adaptPageableMethodReinjectionParams(method, paramsMap); + } else if (pageableMethod.strategy?.kind === 'continuationToken') { + // set the continuation type to token on the Pager and the PagerOptions field in the method options + pageableMethod.returns.type.continuation = 'token'; + for (const field of pageableMethod.options.type.fields) { + if (field.type.kind === 'pagerOptions') { + field.type.continuation = 'token'; + } + } } } } diff --git a/packages/typespec-rust/test/Cargo.toml b/packages/typespec-rust/test/Cargo.toml index c8951d50d..63c072149 100644 --- a/packages/typespec-rust/test/Cargo.toml +++ b/packages/typespec-rust/test/Cargo.toml @@ -96,7 +96,7 @@ rust-version = "1.85" [workspace.dependencies] # Third-party dependencies should be kept up to date with https://github.com/Azure/azure-sdk-for-rust/blob/main/Cargo.lock async-trait = "0.1.88" -azure_core = { git = "https://github.com/Azure/azure-sdk-for-rust.git", rev = "1bc0ef3a9e27af4990435de23e1127155fbba68c", features = [ +azure_core = { git = "https://github.com/Azure/azure-sdk-for-rust.git", rev = "197ddcf43752a5d2b28ae77cb7433f2a6ebcb57e", features = [ "decimal", "reqwest", ] } diff --git a/packages/typespec-rust/test/other/colliding_locals/src/generated/clients/colliding_locals_client.rs b/packages/typespec-rust/test/other/colliding_locals/src/generated/clients/colliding_locals_client.rs index 786fa1b09..7a013313f 100644 --- a/packages/typespec-rust/test/other/colliding_locals/src/generated/clients/colliding_locals_client.rs +++ b/packages/typespec-rust/test/other/colliding_locals/src/generated/clients/colliding_locals_client.rs @@ -315,12 +315,12 @@ impl CollidingLocalsClient { path_var = path_var.replace("{request}", request); path_var = path_var.replace("{url}", url); url_var.append_path(&path_var); - Ok(Pager::from_callback( + Ok(Pager::new( move |_: PagerState, pager_options| { let mut core_req_0 = Request::new(url_var.clone(), Method::Get); core_req_0.insert_header("accept", "application/json"); let pipeline = pipeline.clone(); - async move { + Box::pin(async move { let rsp = pipeline .send( &pager_options.context, @@ -336,7 +336,7 @@ impl CollidingLocalsClient { Ok(PagerResult::Done { response: rsp.into(), }) - } + }) }, Some(options.method_options), )) @@ -388,7 +388,7 @@ impl CollidingLocalsClient { path_var = path_var.replace("{request}", request); path_var = path_var.replace("{url}", url); first_url.append_path(&path_var); - Ok(Pager::from_callback( + Ok(Pager::new( move |next_link: PagerState, pager_options| { let url = match next_link { PagerState::More(next_link) => next_link, @@ -397,7 +397,7 @@ impl CollidingLocalsClient { let mut core_req_0 = Request::new(url, Method::Get); core_req_0.insert_header("accept", "application/json"); let pipeline = pipeline.clone(); - async move { + Box::pin(async move { let rsp = pipeline .send( &pager_options.context, @@ -420,7 +420,7 @@ impl CollidingLocalsClient { }, _ => PagerResult::Done { response: rsp }, }) - } + }) }, Some(options.method_options), )) diff --git a/packages/typespec-rust/test/sdk/appconfiguration/src/generated/clients/azure_app_configuration_client.rs b/packages/typespec-rust/test/sdk/appconfiguration/src/generated/clients/azure_app_configuration_client.rs index 4672224f7..54d5887a8 100644 --- a/packages/typespec-rust/test/sdk/appconfiguration/src/generated/clients/azure_app_configuration_client.rs +++ b/packages/typespec-rust/test/sdk/appconfiguration/src/generated/clients/azure_app_configuration_client.rs @@ -1367,7 +1367,7 @@ impl AzureAppConfigurationClient { } query_builder.build(); let api_version = self.api_version.clone(); - Ok(Pager::from_callback( + Ok(Pager::new( move |next_link: PagerState, pager_options| { let url = match next_link { PagerState::More(next_link) => { @@ -1394,7 +1394,7 @@ impl AzureAppConfigurationClient { request.insert_header("sync-token", sync_token); } let pipeline = pipeline.clone(); - async move { + Box::pin(async move { let rsp = pipeline .send( &pager_options.context, @@ -1417,7 +1417,7 @@ impl AzureAppConfigurationClient { }, _ => PagerResult::Done { response: rsp }, }) - } + }) }, Some(options.method_options), )) @@ -1477,7 +1477,7 @@ impl AzureAppConfigurationClient { } query_builder.build(); let api_version = self.api_version.clone(); - Ok(Pager::from_callback( + Ok(Pager::new( move |next_link: PagerState, pager_options| { let url = match next_link { PagerState::More(next_link) => { @@ -1498,7 +1498,7 @@ impl AzureAppConfigurationClient { request.insert_header("sync-token", sync_token); } let pipeline = pipeline.clone(); - async move { + Box::pin(async move { let rsp = pipeline .send( &pager_options.context, @@ -1521,7 +1521,7 @@ impl AzureAppConfigurationClient { }, _ => PagerResult::Done { response: rsp }, }) - } + }) }, Some(options.method_options), )) @@ -1591,7 +1591,7 @@ impl AzureAppConfigurationClient { } query_builder.build(); let api_version = self.api_version.clone(); - Ok(Pager::from_callback( + Ok(Pager::new( move |next_link: PagerState, pager_options| { let url = match next_link { PagerState::More(next_link) => { @@ -1612,7 +1612,7 @@ impl AzureAppConfigurationClient { request.insert_header("sync-token", sync_token); } let pipeline = pipeline.clone(); - async move { + Box::pin(async move { let rsp = pipeline .send( &pager_options.context, @@ -1635,7 +1635,7 @@ impl AzureAppConfigurationClient { }, _ => PagerResult::Done { response: rsp }, }) - } + }) }, Some(options.method_options), )) @@ -1717,7 +1717,7 @@ impl AzureAppConfigurationClient { } query_builder.build(); let api_version = self.api_version.clone(); - Ok(Pager::from_callback( + Ok(Pager::new( move |next_link: PagerState, pager_options| { let url = match next_link { PagerState::More(next_link) => { @@ -1738,7 +1738,7 @@ impl AzureAppConfigurationClient { request.insert_header("sync-token", sync_token); } let pipeline = pipeline.clone(); - async move { + Box::pin(async move { let rsp = pipeline .send( &pager_options.context, @@ -1761,7 +1761,7 @@ impl AzureAppConfigurationClient { }, _ => PagerResult::Done { response: rsp }, }) - } + }) }, Some(options.method_options), )) @@ -1841,7 +1841,7 @@ impl AzureAppConfigurationClient { } query_builder.build(); let api_version = self.api_version.clone(); - Ok(Pager::from_callback( + Ok(Pager::new( move |next_link: PagerState, pager_options| { let url = match next_link { PagerState::More(next_link) => { @@ -1859,7 +1859,7 @@ impl AzureAppConfigurationClient { request.insert_header("sync-token", sync_token); } let pipeline = pipeline.clone(); - async move { + Box::pin(async move { let rsp = pipeline .send( &pager_options.context, @@ -1882,7 +1882,7 @@ impl AzureAppConfigurationClient { }, _ => PagerResult::Done { response: rsp }, }) - } + }) }, Some(options.method_options), )) diff --git a/packages/typespec-rust/test/sdk/blob_storage/src/generated/clients/blob_container_client.rs b/packages/typespec-rust/test/sdk/blob_storage/src/generated/clients/blob_container_client.rs index c911a996f..8dcae3a7f 100644 --- a/packages/typespec-rust/test/sdk/blob_storage/src/generated/clients/blob_container_client.rs +++ b/packages/typespec-rust/test/sdk/blob_storage/src/generated/clients/blob_container_client.rs @@ -854,7 +854,7 @@ impl BlobContainerClient { pub fn list_blob_flat_segment( &self, options: Option>, - ) -> Result> { + ) -> Result> { let options = options.unwrap_or_default().into_owned(); let pipeline = self.pipeline.clone(); let mut first_url = self.endpoint.clone(); @@ -890,7 +890,7 @@ impl BlobContainerClient { } query_builder.build(); let version = self.version.clone(); - Ok(Pager::from_callback( + Ok(Pager::new( move |marker: PagerState, pager_options| { let mut url = first_url.clone(); if let PagerState::More(marker) = marker { @@ -903,7 +903,7 @@ impl BlobContainerClient { request.insert_header("content-type", "application/xml"); request.insert_header("x-ms-version", &version); let pipeline = pipeline.clone(); - async move { + Box::pin(async move { let rsp = pipeline .send( &pager_options.context, @@ -926,7 +926,7 @@ impl BlobContainerClient { }, _ => PagerResult::Done { response: rsp }, }) - } + }) }, Some(options.method_options), )) @@ -969,7 +969,7 @@ impl BlobContainerClient { &self, delimiter: &str, options: Option>, - ) -> Result> { + ) -> Result> { let options = options.unwrap_or_default().into_owned(); let pipeline = self.pipeline.clone(); let mut first_url = self.endpoint.clone(); @@ -1006,7 +1006,7 @@ impl BlobContainerClient { } query_builder.build(); let version = self.version.clone(); - Ok(Pager::from_callback( + Ok(Pager::new( move |marker: PagerState, pager_options| { let mut url = first_url.clone(); if let PagerState::More(marker) = marker { @@ -1019,7 +1019,7 @@ impl BlobContainerClient { request.insert_header("content-type", "application/xml"); request.insert_header("x-ms-version", &version); let pipeline = pipeline.clone(); - async move { + Box::pin(async move { let rsp = pipeline .send( &pager_options.context, @@ -1042,7 +1042,7 @@ impl BlobContainerClient { }, _ => PagerResult::Done { response: rsp }, }) - } + }) }, Some(options.method_options), )) diff --git a/packages/typespec-rust/test/sdk/blob_storage/src/generated/clients/blob_service_client.rs b/packages/typespec-rust/test/sdk/blob_storage/src/generated/clients/blob_service_client.rs index bf0e4a87f..e3fa83370 100644 --- a/packages/typespec-rust/test/sdk/blob_storage/src/generated/clients/blob_service_client.rs +++ b/packages/typespec-rust/test/sdk/blob_storage/src/generated/clients/blob_service_client.rs @@ -441,7 +441,7 @@ impl BlobServiceClient { pub fn list_containers_segment( &self, options: Option>, - ) -> Result> { + ) -> Result> { let options = options.unwrap_or_default().into_owned(); let pipeline = self.pipeline.clone(); let mut first_url = self.endpoint.clone(); @@ -471,7 +471,7 @@ impl BlobServiceClient { } query_builder.build(); let version = self.version.clone(); - Ok(Pager::from_callback( + Ok(Pager::new( move |marker: PagerState, pager_options| { let mut url = first_url.clone(); if let PagerState::More(marker) = marker { @@ -484,7 +484,7 @@ impl BlobServiceClient { request.insert_header("content-type", "application/xml"); request.insert_header("x-ms-version", &version); let pipeline = pipeline.clone(); - async move { + Box::pin(async move { let rsp = pipeline .send( &pager_options.context, @@ -507,7 +507,7 @@ impl BlobServiceClient { }, _ => PagerResult::Done { response: rsp }, }) - } + }) }, Some(options.method_options), )) diff --git a/packages/typespec-rust/test/sdk/blob_storage/src/generated/models/method_options.rs b/packages/typespec-rust/test/sdk/blob_storage/src/generated/models/method_options.rs index 4e24660ae..d0aaf656f 100644 --- a/packages/typespec-rust/test/sdk/blob_storage/src/generated/models/method_options.rs +++ b/packages/typespec-rust/test/sdk/blob_storage/src/generated/models/method_options.rs @@ -1232,7 +1232,7 @@ pub struct BlobContainerClientListBlobFlatSegmentOptions<'a> { pub maxresults: Option, /// Allows customization of the method call. - pub method_options: PagerOptions<'a>, + pub method_options: PagerOptions<'a, String>, /// Filters the results to return only containers whose name begins with the specified prefix. pub prefix: Option, @@ -1275,7 +1275,7 @@ pub struct BlobContainerClientListBlobHierarchySegmentOptions<'a> { pub maxresults: Option, /// Allows customization of the method call. - pub method_options: PagerOptions<'a>, + pub method_options: PagerOptions<'a, String>, /// Filters the results to return only containers whose name begins with the specified prefix. pub prefix: Option, @@ -1486,7 +1486,7 @@ pub struct BlobServiceClientListContainersSegmentOptions<'a> { pub maxresults: Option, /// Allows customization of the method call. - pub method_options: PagerOptions<'a>, + pub method_options: PagerOptions<'a, String>, /// Filters the results to return only containers whose name begins with the specified prefix. pub prefix: Option, diff --git a/packages/typespec-rust/test/sdk/keyvault_secrets/src/generated/clients/secret_client.rs b/packages/typespec-rust/test/sdk/keyvault_secrets/src/generated/clients/secret_client.rs index daf54b54d..71ed0ff96 100644 --- a/packages/typespec-rust/test/sdk/keyvault_secrets/src/generated/clients/secret_client.rs +++ b/packages/typespec-rust/test/sdk/keyvault_secrets/src/generated/clients/secret_client.rs @@ -309,7 +309,7 @@ impl SecretClient { } query_builder.build(); let api_version = self.api_version.clone(); - Ok(Pager::from_callback( + Ok(Pager::new( move |next_link: PagerState, pager_options| { let url = match next_link { PagerState::More(next_link) => { @@ -324,7 +324,7 @@ impl SecretClient { let mut request = Request::new(url, Method::Get); request.insert_header("accept", "application/json"); let pipeline = pipeline.clone(); - async move { + Box::pin(async move { let rsp = pipeline .send( &pager_options.context, @@ -347,7 +347,7 @@ impl SecretClient { }, _ => PagerResult::Done { response: rsp }, }) - } + }) }, Some(options.method_options), )) @@ -378,7 +378,7 @@ impl SecretClient { } query_builder.build(); let api_version = self.api_version.clone(); - Ok(Pager::from_callback( + Ok(Pager::new( move |next_link: PagerState, pager_options| { let url = match next_link { PagerState::More(next_link) => { @@ -393,7 +393,7 @@ impl SecretClient { let mut request = Request::new(url, Method::Get); request.insert_header("accept", "application/json"); let pipeline = pipeline.clone(); - async move { + Box::pin(async move { let rsp = pipeline .send( &pager_options.context, @@ -416,7 +416,7 @@ impl SecretClient { }, _ => PagerResult::Done { response: rsp }, }) - } + }) }, Some(options.method_options), )) @@ -456,7 +456,7 @@ impl SecretClient { } query_builder.build(); let api_version = self.api_version.clone(); - Ok(Pager::from_callback( + Ok(Pager::new( move |next_link: PagerState, pager_options| { let url = match next_link { PagerState::More(next_link) => { @@ -471,7 +471,7 @@ impl SecretClient { let mut request = Request::new(url, Method::Get); request.insert_header("accept", "application/json"); let pipeline = pipeline.clone(); - async move { + Box::pin(async move { let rsp = pipeline .send( &pager_options.context, @@ -494,7 +494,7 @@ impl SecretClient { }, _ => PagerResult::Done { response: rsp }, }) - } + }) }, Some(options.method_options), )) diff --git a/packages/typespec-rust/test/spector/azure/core/basic/src/generated/clients/basic_client.rs b/packages/typespec-rust/test/spector/azure/core/basic/src/generated/clients/basic_client.rs index 51ead79a8..397ce8bbf 100644 --- a/packages/typespec-rust/test/spector/azure/core/basic/src/generated/clients/basic_client.rs +++ b/packages/typespec-rust/test/spector/azure/core/basic/src/generated/clients/basic_client.rs @@ -371,7 +371,7 @@ impl BasicClient { } query_builder.build(); let api_version = self.api_version.clone(); - Ok(Pager::from_callback( + Ok(Pager::new( move |next_link: PagerState, pager_options| { let url = match next_link { PagerState::More(next_link) => { @@ -386,7 +386,7 @@ impl BasicClient { let mut request = Request::new(url, Method::Get); request.insert_header("accept", "application/json"); let pipeline = pipeline.clone(); - async move { + Box::pin(async move { let rsp = pipeline .send( &pager_options.context, @@ -409,7 +409,7 @@ impl BasicClient { }, _ => PagerResult::Done { response: rsp }, }) - } + }) }, Some(options.method_options), )) diff --git a/packages/typespec-rust/test/spector/azure/core/page/src/generated/clients/page_client.rs b/packages/typespec-rust/test/spector/azure/core/page/src/generated/clients/page_client.rs index 574c75dce..801e7ab52 100644 --- a/packages/typespec-rust/test/spector/azure/core/page/src/generated/clients/page_client.rs +++ b/packages/typespec-rust/test/spector/azure/core/page/src/generated/clients/page_client.rs @@ -103,7 +103,7 @@ impl PageClient { query_builder.set_pair("api-version", &self.api_version); query_builder.build(); let api_version = self.api_version.clone(); - Ok(Pager::from_callback( + Ok(Pager::new( move |next_link: PagerState, pager_options| { let url = match next_link { PagerState::More(next_link) => { @@ -118,7 +118,7 @@ impl PageClient { let mut request = Request::new(url, Method::Get); request.insert_header("accept", "application/json"); let pipeline = pipeline.clone(); - async move { + Box::pin(async move { let rsp = pipeline .send( &pager_options.context, @@ -141,7 +141,7 @@ impl PageClient { }, _ => PagerResult::Done { response: rsp }, }) - } + }) }, Some(options.method_options), )) @@ -165,7 +165,7 @@ impl PageClient { query_builder.set_pair("api-version", &self.api_version); query_builder.build(); let api_version = self.api_version.clone(); - Ok(Pager::from_callback( + Ok(Pager::new( move |next_link: PagerState, pager_options| { let url = match next_link { PagerState::More(next_link) => { @@ -180,7 +180,7 @@ impl PageClient { let mut request = Request::new(url, Method::Get); request.insert_header("accept", "application/json"); let pipeline = pipeline.clone(); - async move { + Box::pin(async move { let rsp = pipeline .send( &pager_options.context, @@ -203,7 +203,7 @@ impl PageClient { }, _ => PagerResult::Done { response: rsp }, }) - } + }) }, Some(options.method_options), )) @@ -230,7 +230,7 @@ impl PageClient { } query_builder.set_pair("select", select); query_builder.build(); - Ok(Pager::from_callback( + Ok(Pager::new( move |next_link: PagerState, pager_options| { let url = match next_link { PagerState::More(next_link) => { @@ -247,7 +247,7 @@ impl PageClient { let mut request = Request::new(url, Method::Get); request.insert_header("accept", "application/json"); let pipeline = pipeline.clone(); - async move { + Box::pin(async move { let rsp = pipeline .send( &pager_options.context, @@ -270,7 +270,7 @@ impl PageClient { }, _ => PagerResult::Done { response: rsp }, }) - } + }) }, Some(options.method_options), )) @@ -299,7 +299,7 @@ impl PageClient { query_builder.set_pair("api-version", &self.api_version); query_builder.build(); let api_version = self.api_version.clone(); - Ok(Pager::from_callback( + Ok(Pager::new( move |next_link: PagerState, pager_options| { let url = match next_link { PagerState::More(next_link) => { @@ -316,7 +316,7 @@ impl PageClient { request.insert_header("content-type", "application/json"); request.set_body(body_input.clone()); let pipeline = pipeline.clone(); - async move { + Box::pin(async move { let rsp = pipeline .send( &pager_options.context, @@ -339,7 +339,7 @@ impl PageClient { }, _ => PagerResult::Done { response: rsp }, }) - } + }) }, Some(options.method_options), )) diff --git a/packages/typespec-rust/test/spector/azure/core/page/src/generated/clients/page_two_models_as_page_item_client.rs b/packages/typespec-rust/test/spector/azure/core/page/src/generated/clients/page_two_models_as_page_item_client.rs index 2f35f0b7d..c9a4d4331 100644 --- a/packages/typespec-rust/test/spector/azure/core/page/src/generated/clients/page_two_models_as_page_item_client.rs +++ b/packages/typespec-rust/test/spector/azure/core/page/src/generated/clients/page_two_models_as_page_item_client.rs @@ -47,7 +47,7 @@ impl PageTwoModelsAsPageItemClient { query_builder.set_pair("api-version", &self.api_version); query_builder.build(); let api_version = self.api_version.clone(); - Ok(Pager::from_callback( + Ok(Pager::new( move |next_link: PagerState, pager_options| { let url = match next_link { PagerState::More(next_link) => { @@ -62,7 +62,7 @@ impl PageTwoModelsAsPageItemClient { let mut request = Request::new(url, Method::Get); request.insert_header("accept", "application/json"); let pipeline = pipeline.clone(); - async move { + Box::pin(async move { let rsp = pipeline .send( &pager_options.context, @@ -85,7 +85,7 @@ impl PageTwoModelsAsPageItemClient { }, _ => PagerResult::Done { response: rsp }, }) - } + }) }, Some(options.method_options), )) @@ -109,7 +109,7 @@ impl PageTwoModelsAsPageItemClient { query_builder.set_pair("api-version", &self.api_version); query_builder.build(); let api_version = self.api_version.clone(); - Ok(Pager::from_callback( + Ok(Pager::new( move |next_link: PagerState, pager_options| { let url = match next_link { PagerState::More(next_link) => { @@ -124,7 +124,7 @@ impl PageTwoModelsAsPageItemClient { let mut request = Request::new(url, Method::Get); request.insert_header("accept", "application/json"); let pipeline = pipeline.clone(); - async move { + Box::pin(async move { let rsp = pipeline .send( &pager_options.context, @@ -147,7 +147,7 @@ impl PageTwoModelsAsPageItemClient { }, _ => PagerResult::Done { response: rsp }, }) - } + }) }, Some(options.method_options), )) diff --git a/packages/typespec-rust/test/spector/azure/payload/pageable/src/generated/clients/pageable_client.rs b/packages/typespec-rust/test/spector/azure/payload/pageable/src/generated/clients/pageable_client.rs index b14deec12..addb78ae8 100644 --- a/packages/typespec-rust/test/spector/azure/payload/pageable/src/generated/clients/pageable_client.rs +++ b/packages/typespec-rust/test/spector/azure/payload/pageable/src/generated/clients/pageable_client.rs @@ -83,7 +83,7 @@ impl PageableClient { query_builder.set_pair("maxpagesize", maxpagesize.to_string()); } query_builder.build(); - Ok(Pager::from_callback( + Ok(Pager::new( move |next_link: PagerState, pager_options| { let url = match next_link { PagerState::More(next_link) => next_link, @@ -92,7 +92,7 @@ impl PageableClient { let mut request = Request::new(url, Method::Get); request.insert_header("accept", "application/json"); let pipeline = pipeline.clone(); - async move { + Box::pin(async move { let rsp = pipeline .send( &pager_options.context, @@ -115,7 +115,7 @@ impl PageableClient { }, _ => PagerResult::Done { response: rsp }, }) - } + }) }, Some(options.method_options), )) diff --git a/packages/typespec-rust/test/spector/azure/resource-manager/method-subscription-id/src/generated/clients/method_subscription_id_operations_client.rs b/packages/typespec-rust/test/spector/azure/resource-manager/method-subscription-id/src/generated/clients/method_subscription_id_operations_client.rs index 2f6be450b..def861700 100644 --- a/packages/typespec-rust/test/spector/azure/resource-manager/method-subscription-id/src/generated/clients/method_subscription_id_operations_client.rs +++ b/packages/typespec-rust/test/spector/azure/resource-manager/method-subscription-id/src/generated/clients/method_subscription_id_operations_client.rs @@ -46,7 +46,7 @@ impl MethodSubscriptionIdOperationsClient { query_builder.set_pair("api-version", &self.api_version); query_builder.build(); let api_version = self.api_version.clone(); - Ok(Pager::from_callback( + Ok(Pager::new( move |next_link: PagerState, pager_options| { let url = match next_link { PagerState::More(next_link) => { @@ -61,7 +61,7 @@ impl MethodSubscriptionIdOperationsClient { let mut request = Request::new(url, Method::Get); request.insert_header("accept", "application/json"); let pipeline = pipeline.clone(); - async move { + Box::pin(async move { let rsp = pipeline .send( &pager_options.context, @@ -84,7 +84,7 @@ impl MethodSubscriptionIdOperationsClient { }, _ => PagerResult::Done { response: rsp }, }) - } + }) }, Some(options.method_options), )) diff --git a/packages/typespec-rust/test/spector/azure/resource-manager/operation-templates/src/generated/clients/operation_templates_operations_client.rs b/packages/typespec-rust/test/spector/azure/resource-manager/operation-templates/src/generated/clients/operation_templates_operations_client.rs index 4a511319f..71e7c8095 100644 --- a/packages/typespec-rust/test/spector/azure/resource-manager/operation-templates/src/generated/clients/operation_templates_operations_client.rs +++ b/packages/typespec-rust/test/spector/azure/resource-manager/operation-templates/src/generated/clients/operation_templates_operations_client.rs @@ -46,7 +46,7 @@ impl OperationTemplatesOperationsClient { query_builder.set_pair("api-version", &self.api_version); query_builder.build(); let api_version = self.api_version.clone(); - Ok(Pager::from_callback( + Ok(Pager::new( move |next_link: PagerState, pager_options| { let url = match next_link { PagerState::More(next_link) => { @@ -61,7 +61,7 @@ impl OperationTemplatesOperationsClient { let mut request = Request::new(url, Method::Get); request.insert_header("accept", "application/json"); let pipeline = pipeline.clone(); - async move { + Box::pin(async move { let rsp = pipeline .send( &pager_options.context, @@ -84,7 +84,7 @@ impl OperationTemplatesOperationsClient { }, _ => PagerResult::Done { response: rsp }, }) - } + }) }, Some(options.method_options), )) diff --git a/packages/typespec-rust/test/spector/azure/resource-manager/resources/src/generated/clients/resources_extensions_resources_client.rs b/packages/typespec-rust/test/spector/azure/resource-manager/resources/src/generated/clients/resources_extensions_resources_client.rs index b19d42a30..d285fb1e0 100644 --- a/packages/typespec-rust/test/spector/azure/resource-manager/resources/src/generated/clients/resources_extensions_resources_client.rs +++ b/packages/typespec-rust/test/spector/azure/resource-manager/resources/src/generated/clients/resources_extensions_resources_client.rs @@ -326,7 +326,7 @@ impl ResourcesExtensionsResourcesClient { query_builder.set_pair("api-version", &self.api_version); query_builder.build(); let api_version = self.api_version.clone(); - Ok(Pager::from_callback( + Ok(Pager::new( move |next_link: PagerState, pager_options| { let url = match next_link { PagerState::More(next_link) => { @@ -341,7 +341,7 @@ impl ResourcesExtensionsResourcesClient { let mut request = Request::new(url, Method::Get); request.insert_header("accept", "application/json"); let pipeline = pipeline.clone(); - async move { + Box::pin(async move { let rsp = pipeline .send( &pager_options.context, @@ -364,7 +364,7 @@ impl ResourcesExtensionsResourcesClient { }, _ => PagerResult::Done { response: rsp }, }) - } + }) }, Some(options.method_options), )) diff --git a/packages/typespec-rust/test/spector/azure/resource-manager/resources/src/generated/clients/resources_location_resources_client.rs b/packages/typespec-rust/test/spector/azure/resource-manager/resources/src/generated/clients/resources_location_resources_client.rs index 8e29d40a2..f541e4e4d 100644 --- a/packages/typespec-rust/test/spector/azure/resource-manager/resources/src/generated/clients/resources_location_resources_client.rs +++ b/packages/typespec-rust/test/spector/azure/resource-manager/resources/src/generated/clients/resources_location_resources_client.rs @@ -231,7 +231,7 @@ impl ResourcesLocationResourcesClient { query_builder.set_pair("api-version", &self.api_version); query_builder.build(); let api_version = self.api_version.clone(); - Ok(Pager::from_callback( + Ok(Pager::new( move |next_link: PagerState, pager_options| { let url = match next_link { PagerState::More(next_link) => { @@ -246,7 +246,7 @@ impl ResourcesLocationResourcesClient { let mut request = Request::new(url, Method::Get); request.insert_header("accept", "application/json"); let pipeline = pipeline.clone(); - async move { + Box::pin(async move { let rsp = pipeline .send( &pager_options.context, @@ -269,7 +269,7 @@ impl ResourcesLocationResourcesClient { }, _ => PagerResult::Done { response: rsp }, }) - } + }) }, Some(options.method_options), )) diff --git a/packages/typespec-rust/test/spector/azure/resource-manager/resources/src/generated/clients/resources_nested_client.rs b/packages/typespec-rust/test/spector/azure/resource-manager/resources/src/generated/clients/resources_nested_client.rs index d93778d7e..bd4005915 100644 --- a/packages/typespec-rust/test/spector/azure/resource-manager/resources/src/generated/clients/resources_nested_client.rs +++ b/packages/typespec-rust/test/spector/azure/resource-manager/resources/src/generated/clients/resources_nested_client.rs @@ -449,7 +449,7 @@ impl ResourcesNestedClient { query_builder.set_pair("api-version", &self.api_version); query_builder.build(); let api_version = self.api_version.clone(); - Ok(Pager::from_callback( + Ok(Pager::new( move |next_link: PagerState, pager_options| { let url = match next_link { PagerState::More(next_link) => { @@ -464,7 +464,7 @@ impl ResourcesNestedClient { let mut request = Request::new(url, Method::Get); request.insert_header("accept", "application/json"); let pipeline = pipeline.clone(); - async move { + Box::pin(async move { let rsp = pipeline .send( &pager_options.context, @@ -487,7 +487,7 @@ impl ResourcesNestedClient { }, _ => PagerResult::Done { response: rsp }, }) - } + }) }, Some(options.method_options), )) diff --git a/packages/typespec-rust/test/spector/azure/resource-manager/resources/src/generated/clients/resources_singleton_client.rs b/packages/typespec-rust/test/spector/azure/resource-manager/resources/src/generated/clients/resources_singleton_client.rs index 08ce695ff..8065f2641 100644 --- a/packages/typespec-rust/test/spector/azure/resource-manager/resources/src/generated/clients/resources_singleton_client.rs +++ b/packages/typespec-rust/test/spector/azure/resource-manager/resources/src/generated/clients/resources_singleton_client.rs @@ -260,7 +260,7 @@ impl ResourcesSingletonClient { query_builder.set_pair("api-version", &self.api_version); query_builder.build(); let api_version = self.api_version.clone(); - Ok(Pager::from_callback( + Ok(Pager::new( move |next_link: PagerState, pager_options| { let url = match next_link { PagerState::More(next_link) => { @@ -275,7 +275,7 @@ impl ResourcesSingletonClient { let mut request = Request::new(url, Method::Get); request.insert_header("accept", "application/json"); let pipeline = pipeline.clone(); - async move { + Box::pin(async move { let rsp = pipeline .send( &pager_options.context, @@ -298,7 +298,7 @@ impl ResourcesSingletonClient { }, _ => PagerResult::Done { response: rsp }, }) - } + }) }, Some(options.method_options), )) diff --git a/packages/typespec-rust/test/spector/azure/resource-manager/resources/src/generated/clients/resources_top_level_client.rs b/packages/typespec-rust/test/spector/azure/resource-manager/resources/src/generated/clients/resources_top_level_client.rs index cb3a32293..e7a5ba779 100644 --- a/packages/typespec-rust/test/spector/azure/resource-manager/resources/src/generated/clients/resources_top_level_client.rs +++ b/packages/typespec-rust/test/spector/azure/resource-manager/resources/src/generated/clients/resources_top_level_client.rs @@ -485,7 +485,7 @@ impl ResourcesTopLevelClient { query_builder.set_pair("api-version", &self.api_version); query_builder.build(); let api_version = self.api_version.clone(); - Ok(Pager::from_callback( + Ok(Pager::new( move |next_link: PagerState, pager_options| { let url = match next_link { PagerState::More(next_link) => { @@ -500,7 +500,7 @@ impl ResourcesTopLevelClient { let mut request = Request::new(url, Method::Get); request.insert_header("accept", "application/json"); let pipeline = pipeline.clone(); - async move { + Box::pin(async move { let rsp = pipeline .send( &pager_options.context, @@ -523,7 +523,7 @@ impl ResourcesTopLevelClient { }, _ => PagerResult::Done { response: rsp }, }) - } + }) }, Some(options.method_options), )) @@ -549,7 +549,7 @@ impl ResourcesTopLevelClient { query_builder.set_pair("api-version", &self.api_version); query_builder.build(); let api_version = self.api_version.clone(); - Ok(Pager::from_callback( + Ok(Pager::new( move |next_link: PagerState, pager_options| { let url = match next_link { PagerState::More(next_link) => { @@ -564,7 +564,7 @@ impl ResourcesTopLevelClient { let mut request = Request::new(url, Method::Get); request.insert_header("accept", "application/json"); let pipeline = pipeline.clone(); - async move { + Box::pin(async move { let rsp = pipeline .send( &pager_options.context, @@ -587,7 +587,7 @@ impl ResourcesTopLevelClient { }, _ => PagerResult::Done { response: rsp }, }) - } + }) }, Some(options.method_options), )) diff --git a/packages/typespec-rust/test/spector/payload/pageable/src/generated/clients/pageable_page_size_client.rs b/packages/typespec-rust/test/spector/payload/pageable/src/generated/clients/pageable_page_size_client.rs index 68388eed8..c26a2e496 100644 --- a/packages/typespec-rust/test/spector/payload/pageable/src/generated/clients/pageable_page_size_client.rs +++ b/packages/typespec-rust/test/spector/payload/pageable/src/generated/clients/pageable_page_size_client.rs @@ -47,12 +47,12 @@ impl PageablePageSizeClient { query_builder.set_pair("pageSize", page_size.to_string()); } query_builder.build(); - Ok(Pager::from_callback( + Ok(Pager::new( move |_: PagerState, pager_options| { let mut request = Request::new(url.clone(), Method::Get); request.insert_header("accept", "application/json"); let pipeline = pipeline.clone(); - async move { + Box::pin(async move { let rsp = pipeline .send( &pager_options.context, @@ -68,7 +68,7 @@ impl PageablePageSizeClient { Ok(PagerResult::Done { response: rsp.into(), }) - } + }) }, Some(options.method_options), )) @@ -87,12 +87,12 @@ impl PageablePageSizeClient { let pipeline = self.pipeline.clone(); let mut url = self.endpoint.clone(); url.append_path("/payload/pageable/pagesize/without-continuation"); - Ok(Pager::from_callback( + Ok(Pager::new( move |_: PagerState, pager_options| { let mut request = Request::new(url.clone(), Method::Get); request.insert_header("accept", "application/json"); let pipeline = pipeline.clone(); - async move { + Box::pin(async move { let rsp = pipeline .send( &pager_options.context, @@ -108,7 +108,7 @@ impl PageablePageSizeClient { Ok(PagerResult::Done { response: rsp.into(), }) - } + }) }, Some(options.method_options), )) diff --git a/packages/typespec-rust/test/spector/payload/pageable/src/generated/clients/pageable_server_driven_pagination_client.rs b/packages/typespec-rust/test/spector/payload/pageable/src/generated/clients/pageable_server_driven_pagination_client.rs index 41608886b..9db474d3f 100644 --- a/packages/typespec-rust/test/spector/payload/pageable/src/generated/clients/pageable_server_driven_pagination_client.rs +++ b/packages/typespec-rust/test/spector/payload/pageable/src/generated/clients/pageable_server_driven_pagination_client.rs @@ -57,7 +57,7 @@ impl PageableServerDrivenPaginationClient { let pipeline = self.pipeline.clone(); let mut first_url = self.endpoint.clone(); first_url.append_path("/payload/pageable/server-driven-pagination/link"); - Ok(Pager::from_callback( + Ok(Pager::new( move |next: PagerState, pager_options| { let url = match next { PagerState::More(next) => next, @@ -66,7 +66,7 @@ impl PageableServerDrivenPaginationClient { let mut request = Request::new(url, Method::Get); request.insert_header("accept", "application/json"); let pipeline = pipeline.clone(); - async move { + Box::pin(async move { let rsp = pipeline .send( &pager_options.context, @@ -89,7 +89,7 @@ impl PageableServerDrivenPaginationClient { }, _ => PagerResult::Done { response: rsp }, }) - } + }) }, Some(options.method_options), )) @@ -108,7 +108,7 @@ impl PageableServerDrivenPaginationClient { let pipeline = self.pipeline.clone(); let mut first_url = self.endpoint.clone(); first_url.append_path("/payload/pageable/server-driven-pagination/link-string"); - Ok(Pager::from_callback( + Ok(Pager::new( move |next: PagerState, pager_options| { let url = match next { PagerState::More(next) => next, @@ -117,7 +117,7 @@ impl PageableServerDrivenPaginationClient { let mut request = Request::new(url, Method::Get); request.insert_header("accept", "application/json"); let pipeline = pipeline.clone(); - async move { + Box::pin(async move { let rsp = pipeline .send( &pager_options.context, @@ -140,7 +140,7 @@ impl PageableServerDrivenPaginationClient { }, _ => PagerResult::Done { response: rsp }, }) - } + }) }, Some(options.method_options), )) @@ -159,7 +159,7 @@ impl PageableServerDrivenPaginationClient { let pipeline = self.pipeline.clone(); let mut first_url = self.endpoint.clone(); first_url.append_path("/payload/pageable/server-driven-pagination/nested-link"); - Ok(Pager::from_callback( + Ok(Pager::new( move |next: PagerState, pager_options| { let url = match next { PagerState::More(next) => next, @@ -168,7 +168,7 @@ impl PageableServerDrivenPaginationClient { let mut request = Request::new(url, Method::Get); request.insert_header("accept", "application/json"); let pipeline = pipeline.clone(); - async move { + Box::pin(async move { let rsp = pipeline .send( &pager_options.context, @@ -193,7 +193,7 @@ impl PageableServerDrivenPaginationClient { _ => PagerResult::Done { response: rsp }, }, ) - } + }) }, Some(options.method_options), )) diff --git a/packages/typespec-rust/test/spector/payload/pageable/src/generated/clients/pageable_server_driven_pagination_continuation_token_client.rs b/packages/typespec-rust/test/spector/payload/pageable/src/generated/clients/pageable_server_driven_pagination_continuation_token_client.rs index 2c6990d93..4b520de20 100644 --- a/packages/typespec-rust/test/spector/payload/pageable/src/generated/clients/pageable_server_driven_pagination_continuation_token_client.rs +++ b/packages/typespec-rust/test/spector/payload/pageable/src/generated/clients/pageable_server_driven_pagination_continuation_token_client.rs @@ -19,7 +19,8 @@ use azure_core::{ error::CheckSuccessOptions, http::{ pager::{PagerResult, PagerState}, - Method, Pager, Pipeline, PipelineSendOptions, RawResponse, Request, Response, Url, UrlExt, + JsonFormat, Method, Pager, Pipeline, PipelineSendOptions, RawResponse, Request, Response, + Url, UrlExt, }, json, tracing, Result, }; @@ -46,7 +47,7 @@ impl PageableServerDrivenPaginationContinuationTokenClient { pub fn list_request_header_nested_response_body( &self, options: Option>, - ) -> Result> { + ) -> Result> { let options = options.unwrap_or_default().into_owned(); let pipeline = self.pipeline.clone(); let mut first_url = self.endpoint.clone(); @@ -56,7 +57,7 @@ impl PageableServerDrivenPaginationContinuationTokenClient { query_builder.set_pair("bar", bar); } query_builder.build(); - Ok(Pager::from_callback( + Ok(Pager::new( move |token: PagerState, pager_options| { let url = first_url.clone(); let mut request = Request::new(url, Method::Get); @@ -72,7 +73,7 @@ impl PageableServerDrivenPaginationContinuationTokenClient { request.insert_header("token", token); } let pipeline = pipeline.clone(); - async move { + Box::pin(async move { let rsp = pipeline .send( &pager_options.context, @@ -100,7 +101,7 @@ impl PageableServerDrivenPaginationContinuationTokenClient { _ => PagerResult::Done { response: rsp }, }, ) - } + }) }, Some(options.method_options), )) @@ -116,7 +117,7 @@ impl PageableServerDrivenPaginationContinuationTokenClient { pub fn list_request_header_response_body( &self, options: Option>, - ) -> Result> { + ) -> Result> { let options = options.unwrap_or_default().into_owned(); let pipeline = self.pipeline.clone(); let mut first_url = self.endpoint.clone(); @@ -126,7 +127,7 @@ impl PageableServerDrivenPaginationContinuationTokenClient { query_builder.set_pair("bar", bar); } query_builder.build(); - Ok(Pager::from_callback( + Ok(Pager::new( move |token: PagerState, pager_options| { let url = first_url.clone(); let mut request = Request::new(url, Method::Get); @@ -142,7 +143,7 @@ impl PageableServerDrivenPaginationContinuationTokenClient { request.insert_header("token", token); } let pipeline = pipeline.clone(); - async move { + Box::pin(async move { let rsp = pipeline .send( &pager_options.context, @@ -165,7 +166,7 @@ impl PageableServerDrivenPaginationContinuationTokenClient { }, _ => PagerResult::Done { response: rsp }, }) - } + }) }, Some(options.method_options), )) @@ -204,7 +205,7 @@ impl PageableServerDrivenPaginationContinuationTokenClient { pub fn list_request_header_response_header( &self, options: Option>, - ) -> Result> { + ) -> Result> { let options = options.unwrap_or_default().into_owned(); let pipeline = self.pipeline.clone(); let mut first_url = self.endpoint.clone(); @@ -214,7 +215,7 @@ impl PageableServerDrivenPaginationContinuationTokenClient { query_builder.set_pair("bar", bar); } query_builder.build(); - Ok(Pager::from_callback( + Ok(Pager::new( move |token: PagerState, pager_options| { let url = first_url.clone(); let mut request = Request::new(url, Method::Get); @@ -230,7 +231,7 @@ impl PageableServerDrivenPaginationContinuationTokenClient { request.insert_header("token", token); } let pipeline = pipeline.clone(); - async move { + Box::pin(async move { let rsp: Response = pipeline .send( &pager_options.context, @@ -251,7 +252,7 @@ impl PageableServerDrivenPaginationContinuationTokenClient { }, _ => PagerResult::Done { response: rsp }, }) - } + }) }, Some(options.method_options), )) @@ -267,7 +268,7 @@ impl PageableServerDrivenPaginationContinuationTokenClient { pub fn list_request_query_nested_response_body( &self, options: Option>, - ) -> Result> { + ) -> Result> { let options = options.unwrap_or_default().into_owned(); let pipeline = self.pipeline.clone(); let mut first_url = self.endpoint.clone(); @@ -280,7 +281,7 @@ impl PageableServerDrivenPaginationContinuationTokenClient { query_builder.set_pair("token", token); } query_builder.build(); - Ok(Pager::from_callback( + Ok(Pager::new( move |token: PagerState, pager_options| { let mut url = first_url.clone(); if let PagerState::More(token) = token { @@ -294,7 +295,7 @@ impl PageableServerDrivenPaginationContinuationTokenClient { request.insert_header("foo", foo); } let pipeline = pipeline.clone(); - async move { + Box::pin(async move { let rsp = pipeline .send( &pager_options.context, @@ -322,7 +323,7 @@ impl PageableServerDrivenPaginationContinuationTokenClient { _ => PagerResult::Done { response: rsp }, }, ) - } + }) }, Some(options.method_options), )) @@ -338,7 +339,7 @@ impl PageableServerDrivenPaginationContinuationTokenClient { pub fn list_request_query_response_body( &self, options: Option>, - ) -> Result> { + ) -> Result> { let options = options.unwrap_or_default().into_owned(); let pipeline = self.pipeline.clone(); let mut first_url = self.endpoint.clone(); @@ -351,7 +352,7 @@ impl PageableServerDrivenPaginationContinuationTokenClient { query_builder.set_pair("token", token); } query_builder.build(); - Ok(Pager::from_callback( + Ok(Pager::new( move |token: PagerState, pager_options| { let mut url = first_url.clone(); if let PagerState::More(token) = token { @@ -365,7 +366,7 @@ impl PageableServerDrivenPaginationContinuationTokenClient { request.insert_header("foo", foo); } let pipeline = pipeline.clone(); - async move { + Box::pin(async move { let rsp = pipeline .send( &pager_options.context, @@ -388,7 +389,7 @@ impl PageableServerDrivenPaginationContinuationTokenClient { }, _ => PagerResult::Done { response: rsp }, }) - } + }) }, Some(options.method_options), )) @@ -427,7 +428,7 @@ impl PageableServerDrivenPaginationContinuationTokenClient { pub fn list_request_query_response_header( &self, options: Option>, - ) -> Result> { + ) -> Result> { let options = options.unwrap_or_default().into_owned(); let pipeline = self.pipeline.clone(); let mut first_url = self.endpoint.clone(); @@ -440,7 +441,7 @@ impl PageableServerDrivenPaginationContinuationTokenClient { query_builder.set_pair("token", token); } query_builder.build(); - Ok(Pager::from_callback( + Ok(Pager::new( move |token: PagerState, pager_options| { let mut url = first_url.clone(); if let PagerState::More(token) = token { @@ -454,7 +455,7 @@ impl PageableServerDrivenPaginationContinuationTokenClient { request.insert_header("foo", foo); } let pipeline = pipeline.clone(); - async move { + Box::pin(async move { let rsp: Response = pipeline .send( &pager_options.context, @@ -475,7 +476,7 @@ impl PageableServerDrivenPaginationContinuationTokenClient { }, _ => PagerResult::Done { response: rsp }, }) - } + }) }, Some(options.method_options), )) diff --git a/packages/typespec-rust/test/spector/payload/pageable/src/generated/models/method_options.rs b/packages/typespec-rust/test/spector/payload/pageable/src/generated/models/method_options.rs index df094c898..58a0bc756 100644 --- a/packages/typespec-rust/test/spector/payload/pageable/src/generated/models/method_options.rs +++ b/packages/typespec-rust/test/spector/payload/pageable/src/generated/models/method_options.rs @@ -111,7 +111,7 @@ pub struct PageableServerDrivenPaginationContinuationTokenClientListRequestHeade pub foo: Option, /// Allows customization of the method call. - pub method_options: PagerOptions<'a>, + pub method_options: PagerOptions<'a, String>, pub token: Option, } @@ -145,7 +145,7 @@ pub struct PageableServerDrivenPaginationContinuationTokenClientListRequestHeade pub foo: Option, /// Allows customization of the method call. - pub method_options: PagerOptions<'a>, + pub method_options: PagerOptions<'a, String>, pub token: Option, } @@ -175,7 +175,7 @@ pub struct PageableServerDrivenPaginationContinuationTokenClientListRequestHeade pub foo: Option, /// Allows customization of the method call. - pub method_options: PagerOptions<'a>, + pub method_options: PagerOptions<'a, String>, pub token: Option, } @@ -207,7 +207,7 @@ pub struct PageableServerDrivenPaginationContinuationTokenClientListRequestQuery pub foo: Option, /// Allows customization of the method call. - pub method_options: PagerOptions<'a>, + pub method_options: PagerOptions<'a, String>, pub token: Option, } @@ -241,7 +241,7 @@ pub struct PageableServerDrivenPaginationContinuationTokenClientListRequestQuery pub foo: Option, /// Allows customization of the method call. - pub method_options: PagerOptions<'a>, + pub method_options: PagerOptions<'a, String>, pub token: Option, } @@ -271,7 +271,7 @@ pub struct PageableServerDrivenPaginationContinuationTokenClientListRequestQuery pub foo: Option, /// Allows customization of the method call. - pub method_options: PagerOptions<'a>, + pub method_options: PagerOptions<'a, String>, pub token: Option, }