mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-23 00:54:20 +01:00
cln-rpc: Allow access to deprecated fields in conversions
This silences a compilation warning about accessing a deprecated field. This was triggering on each build and we'll notice when they go away, so why upset users with it?
This commit is contained in:
432
cln-grpc/src/convert.rs
generated
432
cln-grpc/src/convert.rs
generated
File diff suppressed because it is too large
Load Diff
@@ -247,9 +247,17 @@ class GrpcConverterGenerator(IGenerator):
|
|||||||
self.generate_composite(prefix, f)
|
self.generate_composite(prefix, f)
|
||||||
|
|
||||||
pbname = self.to_camel_case(field.typename)
|
pbname = self.to_camel_case(field.typename)
|
||||||
|
|
||||||
|
# If any of the field accesses would result in a deprecated
|
||||||
|
# warning we mark the construction here to allow deprecated
|
||||||
|
# fields being access.
|
||||||
|
|
||||||
|
has_deprecated = any([f.deprecated for f in field.fields])
|
||||||
|
deprecated = ",deprecated" if has_deprecated else ""
|
||||||
|
|
||||||
# And now we can convert the current field:
|
# And now we can convert the current field:
|
||||||
self.write(f"""\
|
self.write(f"""\
|
||||||
#[allow(unused_variables,deprecated)]
|
#[allow(unused_variables{deprecated})]
|
||||||
impl From<{prefix}::{field.typename}> for pb::{pbname} {{
|
impl From<{prefix}::{field.typename}> for pb::{pbname} {{
|
||||||
fn from(c: {prefix}::{field.typename}) -> Self {{
|
fn from(c: {prefix}::{field.typename}) -> Self {{
|
||||||
Self {{
|
Self {{
|
||||||
@@ -406,10 +414,13 @@ class GrpcUnconverterGenerator(GrpcConverterGenerator):
|
|||||||
elif isinstance(f, CompositeField):
|
elif isinstance(f, CompositeField):
|
||||||
self.generate_composite(prefix, f)
|
self.generate_composite(prefix, f)
|
||||||
|
|
||||||
|
has_deprecated = any([f.deprecated for f in field.fields])
|
||||||
|
deprecated = ",deprecated" if has_deprecated else ""
|
||||||
|
|
||||||
pbname = self.to_camel_case(field.typename)
|
pbname = self.to_camel_case(field.typename)
|
||||||
# And now we can convert the current field:
|
# And now we can convert the current field:
|
||||||
self.write(f"""\
|
self.write(f"""\
|
||||||
#[allow(unused_variables,deprecated)]
|
#[allow(unused_variables{deprecated})]
|
||||||
impl From<pb::{pbname}> for {prefix}::{field.typename} {{
|
impl From<pb::{pbname}> for {prefix}::{field.typename} {{
|
||||||
fn from(c: pb::{pbname}) -> Self {{
|
fn from(c: pb::{pbname}) -> Self {{
|
||||||
Self {{
|
Self {{
|
||||||
|
|||||||
Reference in New Issue
Block a user