#[derive(Clone, Debug, Default)]
pub struct AuthorizeTargetsRequestView<'a> {
pub targets: ::buffa::MapView<
'a,
&'a str,
super::super::__buffa::view::AuthSegmentsView<'a>,
>,
}
impl<'a> ::buffa::MessageView<'a> for AuthorizeTargetsRequestView<'a> {
type Owned = super::super::AuthorizeTargetsRequest;
fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
<Self as ::buffa::MessageView>::decode_view_ctx(
buf,
::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit),
)
}
fn decode_view_with_ctx(
buf: &'a [u8],
ctx: ::buffa::DecodeContext<'_>,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
<Self as ::buffa::MessageView>::decode_view_ctx(buf, ctx)
}
fn merge_view_field(
&mut self,
tag: ::buffa::encoding::Tag,
cur: &'a [u8],
_before_tag: &'a [u8],
ctx: ::buffa::DecodeContext<'_>,
) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> {
let _ = ctx;
#[allow(unused_variables)]
let view = self;
let mut cur = cur;
match tag.field_number() {
1u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
let entry_bytes = ::buffa::types::borrow_bytes(&mut cur)?;
let mut entry_cur: &'a [u8] = entry_bytes;
let mut key = "";
let mut val = ::core::default::Default::default();
while !entry_cur.is_empty() {
let entry_tag = ::buffa::encoding::Tag::decode(&mut entry_cur)?;
match entry_tag.field_number() {
1 => {
::buffa::encoding::check_wire_type(
entry_tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
key = ::buffa::types::borrow_str(&mut entry_cur)?;
}
2 => {
::buffa::encoding::check_wire_type(
entry_tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
let __sub_ctx = ctx.descend()?;
let sub = ::buffa::types::borrow_bytes(&mut entry_cur)?;
val = <super::super::__buffa::view::AuthSegmentsView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?;
}
_ => {
::buffa::encoding::skip_field_depth(
entry_tag,
&mut entry_cur,
ctx.depth(),
)?;
}
}
}
view.targets.push(key, val);
}
_ => {
::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
}
}
::core::result::Result::Ok(cur)
}
fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::AuthorizeTargetsRequest,
::buffa::DecodeError,
> {
self.to_owned_from_source(None)
}
#[allow(clippy::useless_conversion, clippy::needless_update)]
fn to_owned_from_source(
&self,
__buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>,
) -> ::core::result::Result<
super::super::AuthorizeTargetsRequest,
::buffa::DecodeError,
> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::AuthorizeTargetsRequest {
targets: self
.targets
.iter()
.map(|(k, v)| {
::core::result::Result::<
_,
::buffa::DecodeError,
>::Ok((k.to_string(), v.to_owned_from_source(__buffa_src)?))
})
.collect::<::core::result::Result<_, ::buffa::DecodeError>>()?,
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for AuthorizeTargetsRequestView<'a> {
#[allow(clippy::needless_borrow, clippy::let_and_return)]
fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
let mut size = 0u32;
#[allow(clippy::for_kv_map)]
for (k, v) in &self.targets {
let entry_size: u32 = 1u32 + ::buffa::types::string_encoded_len(k) as u32
+ 1u32
+ {
let __slot = __cache.reserve();
let inner = v.compute_size(__cache);
__cache.set(__slot, inner);
::buffa::encoding::varint_len(inner as u64) as u32 + inner
};
size
+= 1u32 + ::buffa::encoding::varint_len(entry_size as u64) as u32
+ entry_size;
}
size
}
#[allow(clippy::needless_borrow)]
fn write_to(
&self,
__cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::bytes::BufMut,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
for (k, v) in &self.targets {
let __v_len = __cache.consume_next();
let entry_size: u32 = 1u32 + ::buffa::types::string_encoded_len(k) as u32
+ 1u32
+ (::buffa::encoding::varint_len(__v_len as u64) as u32 + __v_len);
::buffa::encoding::Tag::new(
1u32,
::buffa::encoding::WireType::LengthDelimited,
)
.encode(buf);
::buffa::encoding::encode_varint(entry_size as u64, buf);
::buffa::encoding::Tag::new(
1u32,
::buffa::encoding::WireType::LengthDelimited,
)
.encode(buf);
::buffa::types::encode_string(k, buf);
::buffa::encoding::Tag::new(
2u32,
::buffa::encoding::WireType::LengthDelimited,
)
.encode(buf);
::buffa::encoding::encode_varint(__v_len as u64, buf);
v.write_to(__cache, buf);
}
}
}
impl<'__a> ::serde::Serialize for AuthorizeTargetsRequestView<'__a> {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
use ::serde::ser::SerializeMap as _;
let mut __map = __s.serialize_map(::core::option::Option::None)?;
if !self.targets.is_empty() {
struct _WM<'__a, '__x>(
&'__x ::buffa::MapView<
'__x,
&'__a str,
super::super::__buffa::view::AuthSegmentsView<'__a>,
>,
);
impl<'__a> ::serde::Serialize for _WM<'__a, '_> {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
use ::serde::ser::SerializeMap as _;
let mut __m = __s
.serialize_map(::core::option::Option::Some(self.0.len()))?;
for (k, v) in self.0.iter_unique() {
__m.serialize_entry(k, v)?;
}
__m.end()
}
}
__map.serialize_entry("targets", &_WM(&self.targets))?;
}
__map.end()
}
}
impl<'a> ::buffa::MessageName for AuthorizeTargetsRequestView<'a> {
const PACKAGE: &'static str = "anapaya.wap.v1";
const NAME: &'static str = "AuthorizeTargetsRequest";
const FULL_NAME: &'static str = "anapaya.wap.v1.AuthorizeTargetsRequest";
const TYPE_URL: &'static str = "type.googleapis.com/anapaya.wap.v1.AuthorizeTargetsRequest";
}
::buffa::impl_default_view_instance!(AuthorizeTargetsRequestView);
::buffa::impl_view_reborrow!(AuthorizeTargetsRequestView);
#[derive(Clone, Debug)]
pub struct AuthorizeTargetsRequestOwnedView(
::buffa::OwnedView<AuthorizeTargetsRequestView<'static>>,
);
impl AuthorizeTargetsRequestOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
AuthorizeTargetsRequestOwnedView(::buffa::OwnedView::decode(bytes)?),
)
}
pub fn decode_with_options(
bytes: ::buffa::bytes::Bytes,
opts: &::buffa::DecodeOptions,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
AuthorizeTargetsRequestOwnedView(
::buffa::OwnedView::decode_with_options(bytes, opts)?,
),
)
}
pub fn from_owned(
msg: &super::super::AuthorizeTargetsRequest,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
AuthorizeTargetsRequestOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &AuthorizeTargetsRequestView<'_> {
self.0.reborrow()
}
pub fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::AuthorizeTargetsRequest,
::buffa::DecodeError,
> {
self.0.to_owned_message()
}
#[must_use]
pub fn bytes(&self) -> &::buffa::bytes::Bytes {
self.0.bytes()
}
#[must_use]
pub fn into_bytes(self) -> ::buffa::bytes::Bytes {
self.0.into_bytes()
}
#[must_use]
pub fn targets(
&self,
) -> &::buffa::MapView<
'_,
&'_ str,
super::super::__buffa::view::AuthSegmentsView<'_>,
> {
&self.0.reborrow().targets
}
}
impl ::core::convert::From<::buffa::OwnedView<AuthorizeTargetsRequestView<'static>>>
for AuthorizeTargetsRequestOwnedView {
fn from(inner: ::buffa::OwnedView<AuthorizeTargetsRequestView<'static>>) -> Self {
AuthorizeTargetsRequestOwnedView(inner)
}
}
impl ::core::convert::From<AuthorizeTargetsRequestOwnedView>
for ::buffa::OwnedView<AuthorizeTargetsRequestView<'static>> {
fn from(wrapper: AuthorizeTargetsRequestOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<AuthorizeTargetsRequestView<'static>>>
for AuthorizeTargetsRequestOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<AuthorizeTargetsRequestView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::AuthorizeTargetsRequest {
type View<'a> = AuthorizeTargetsRequestView<'a>;
type ViewHandle = AuthorizeTargetsRequestOwnedView;
}
impl ::serde::Serialize for AuthorizeTargetsRequestOwnedView {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
::serde::Serialize::serialize(&self.0, __s)
}
}
#[derive(Clone, Debug, Default)]
pub struct AuthSegmentsView<'a> {
pub up_segments: ::buffa::RepeatedView<
'a,
::scion_protobuf::proto::control_plane::v1::__buffa::view::PathSegmentView<'a>,
>,
pub down_segments: ::buffa::RepeatedView<
'a,
::scion_protobuf::proto::control_plane::v1::__buffa::view::PathSegmentView<'a>,
>,
pub core_segments: ::buffa::RepeatedView<
'a,
::scion_protobuf::proto::control_plane::v1::__buffa::view::PathSegmentView<'a>,
>,
}
impl<'a> ::buffa::MessageView<'a> for AuthSegmentsView<'a> {
type Owned = super::super::AuthSegments;
fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
<Self as ::buffa::MessageView>::decode_view_ctx(
buf,
::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit),
)
}
fn decode_view_with_ctx(
buf: &'a [u8],
ctx: ::buffa::DecodeContext<'_>,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
<Self as ::buffa::MessageView>::decode_view_ctx(buf, ctx)
}
fn merge_view_field(
&mut self,
tag: ::buffa::encoding::Tag,
cur: &'a [u8],
_before_tag: &'a [u8],
ctx: ::buffa::DecodeContext<'_>,
) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> {
let _ = ctx;
#[allow(unused_variables)]
let view = self;
let mut cur = cur;
match tag.field_number() {
1u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
let __sub_ctx = ctx.descend()?;
let sub = ::buffa::types::borrow_bytes(&mut cur)?;
view.up_segments
.push(
<::scion_protobuf::proto::control_plane::v1::__buffa::view::PathSegmentView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
2u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
let __sub_ctx = ctx.descend()?;
let sub = ::buffa::types::borrow_bytes(&mut cur)?;
view.down_segments
.push(
<::scion_protobuf::proto::control_plane::v1::__buffa::view::PathSegmentView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
3u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
let __sub_ctx = ctx.descend()?;
let sub = ::buffa::types::borrow_bytes(&mut cur)?;
view.core_segments
.push(
<::scion_protobuf::proto::control_plane::v1::__buffa::view::PathSegmentView as ::buffa::MessageView>::decode_view_ctx(
sub,
__sub_ctx,
)?,
);
}
_ => {
::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
}
}
::core::result::Result::Ok(cur)
}
fn to_owned_message(
&self,
) -> ::core::result::Result<super::super::AuthSegments, ::buffa::DecodeError> {
self.to_owned_from_source(None)
}
#[allow(clippy::useless_conversion, clippy::needless_update)]
fn to_owned_from_source(
&self,
__buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>,
) -> ::core::result::Result<super::super::AuthSegments, ::buffa::DecodeError> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::AuthSegments {
up_segments: self
.up_segments
.iter()
.map(|v| v.to_owned_from_source(__buffa_src))
.collect::<::core::result::Result<_, ::buffa::DecodeError>>()?,
down_segments: self
.down_segments
.iter()
.map(|v| v.to_owned_from_source(__buffa_src))
.collect::<::core::result::Result<_, ::buffa::DecodeError>>()?,
core_segments: self
.core_segments
.iter()
.map(|v| v.to_owned_from_source(__buffa_src))
.collect::<::core::result::Result<_, ::buffa::DecodeError>>()?,
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for AuthSegmentsView<'a> {
#[allow(clippy::needless_borrow, clippy::let_and_return)]
fn compute_size(&self, __cache: &mut ::buffa::SizeCache) -> u32 {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
let mut size = 0u32;
for v in &self.up_segments {
let __slot = __cache.reserve();
let inner_size = v.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
+ inner_size;
}
for v in &self.down_segments {
let __slot = __cache.reserve();
let inner_size = v.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
+ inner_size;
}
for v in &self.core_segments {
let __slot = __cache.reserve();
let inner_size = v.compute_size(__cache);
__cache.set(__slot, inner_size);
size
+= 1u32 + ::buffa::encoding::varint_len(inner_size as u64) as u32
+ inner_size;
}
size
}
#[allow(clippy::needless_borrow)]
fn write_to(
&self,
__cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::bytes::BufMut,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
for v in &self.up_segments {
::buffa::types::put_len_delimited_header(1u32, __cache.consume_next(), buf);
v.write_to(__cache, buf);
}
for v in &self.down_segments {
::buffa::types::put_len_delimited_header(2u32, __cache.consume_next(), buf);
v.write_to(__cache, buf);
}
for v in &self.core_segments {
::buffa::types::put_len_delimited_header(3u32, __cache.consume_next(), buf);
v.write_to(__cache, buf);
}
}
}
impl<'__a> ::serde::Serialize for AuthSegmentsView<'__a> {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
use ::serde::ser::SerializeMap as _;
let mut __map = __s.serialize_map(::core::option::Option::None)?;
if !self.up_segments.is_empty() {
__map.serialize_entry("upSegments", &*self.up_segments)?;
}
if !self.down_segments.is_empty() {
__map.serialize_entry("downSegments", &*self.down_segments)?;
}
if !self.core_segments.is_empty() {
__map.serialize_entry("coreSegments", &*self.core_segments)?;
}
__map.end()
}
}
impl<'a> ::buffa::MessageName for AuthSegmentsView<'a> {
const PACKAGE: &'static str = "anapaya.wap.v1";
const NAME: &'static str = "AuthSegments";
const FULL_NAME: &'static str = "anapaya.wap.v1.AuthSegments";
const TYPE_URL: &'static str = "type.googleapis.com/anapaya.wap.v1.AuthSegments";
}
::buffa::impl_default_view_instance!(AuthSegmentsView);
::buffa::impl_view_reborrow!(AuthSegmentsView);
#[derive(Clone, Debug)]
pub struct AuthSegmentsOwnedView(::buffa::OwnedView<AuthSegmentsView<'static>>);
impl AuthSegmentsOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
AuthSegmentsOwnedView(::buffa::OwnedView::decode(bytes)?),
)
}
pub fn decode_with_options(
bytes: ::buffa::bytes::Bytes,
opts: &::buffa::DecodeOptions,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
AuthSegmentsOwnedView(::buffa::OwnedView::decode_with_options(bytes, opts)?),
)
}
pub fn from_owned(
msg: &super::super::AuthSegments,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
AuthSegmentsOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &AuthSegmentsView<'_> {
self.0.reborrow()
}
pub fn to_owned_message(
&self,
) -> ::core::result::Result<super::super::AuthSegments, ::buffa::DecodeError> {
self.0.to_owned_message()
}
#[must_use]
pub fn bytes(&self) -> &::buffa::bytes::Bytes {
self.0.bytes()
}
#[must_use]
pub fn into_bytes(self) -> ::buffa::bytes::Bytes {
self.0.into_bytes()
}
#[must_use]
pub fn up_segments(
&self,
) -> &::buffa::RepeatedView<
'_,
::scion_protobuf::proto::control_plane::v1::__buffa::view::PathSegmentView<'_>,
> {
&self.0.reborrow().up_segments
}
#[must_use]
pub fn down_segments(
&self,
) -> &::buffa::RepeatedView<
'_,
::scion_protobuf::proto::control_plane::v1::__buffa::view::PathSegmentView<'_>,
> {
&self.0.reborrow().down_segments
}
#[must_use]
pub fn core_segments(
&self,
) -> &::buffa::RepeatedView<
'_,
::scion_protobuf::proto::control_plane::v1::__buffa::view::PathSegmentView<'_>,
> {
&self.0.reborrow().core_segments
}
}
impl ::core::convert::From<::buffa::OwnedView<AuthSegmentsView<'static>>>
for AuthSegmentsOwnedView {
fn from(inner: ::buffa::OwnedView<AuthSegmentsView<'static>>) -> Self {
AuthSegmentsOwnedView(inner)
}
}
impl ::core::convert::From<AuthSegmentsOwnedView>
for ::buffa::OwnedView<AuthSegmentsView<'static>> {
fn from(wrapper: AuthSegmentsOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<AuthSegmentsView<'static>>>
for AuthSegmentsOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<AuthSegmentsView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::AuthSegments {
type View<'a> = AuthSegmentsView<'a>;
type ViewHandle = AuthSegmentsOwnedView;
}
impl ::serde::Serialize for AuthSegmentsOwnedView {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
::serde::Serialize::serialize(&self.0, __s)
}
}
#[derive(Clone, Debug, Default)]
pub struct AuthorizeTargetsResponseView<'a> {
pub client_ip: &'a str,
pub wap_id: &'a str,
pub data_plane_port: u32,
pub expiry_time: u64,
}
impl<'a> ::buffa::MessageView<'a> for AuthorizeTargetsResponseView<'a> {
type Owned = super::super::AuthorizeTargetsResponse;
fn decode_view(buf: &'a [u8]) -> ::core::result::Result<Self, ::buffa::DecodeError> {
let __limit = ::core::cell::Cell::new(::buffa::DEFAULT_UNKNOWN_FIELD_LIMIT);
<Self as ::buffa::MessageView>::decode_view_ctx(
buf,
::buffa::DecodeContext::new(::buffa::RECURSION_LIMIT, &__limit),
)
}
fn decode_view_with_ctx(
buf: &'a [u8],
ctx: ::buffa::DecodeContext<'_>,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
<Self as ::buffa::MessageView>::decode_view_ctx(buf, ctx)
}
fn merge_view_field(
&mut self,
tag: ::buffa::encoding::Tag,
cur: &'a [u8],
_before_tag: &'a [u8],
ctx: ::buffa::DecodeContext<'_>,
) -> ::core::result::Result<&'a [u8], ::buffa::DecodeError> {
let _ = ctx;
#[allow(unused_variables)]
let view = self;
let mut cur = cur;
match tag.field_number() {
1u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.client_ip = ::buffa::types::borrow_str(&mut cur)?;
}
2u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.wap_id = ::buffa::types::borrow_str(&mut cur)?;
}
3u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.data_plane_port = ::buffa::types::decode_uint32(&mut cur)?;
}
4u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::Varint,
)?;
view.expiry_time = ::buffa::types::decode_uint64(&mut cur)?;
}
_ => {
::buffa::encoding::skip_field_depth(tag, &mut cur, ctx.depth())?;
}
}
::core::result::Result::Ok(cur)
}
fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::AuthorizeTargetsResponse,
::buffa::DecodeError,
> {
self.to_owned_from_source(None)
}
#[allow(clippy::useless_conversion, clippy::needless_update)]
fn to_owned_from_source(
&self,
__buffa_src: ::core::option::Option<&::buffa::bytes::Bytes>,
) -> ::core::result::Result<
super::super::AuthorizeTargetsResponse,
::buffa::DecodeError,
> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::AuthorizeTargetsResponse {
client_ip: self.client_ip.to_string(),
wap_id: self.wap_id.to_string(),
data_plane_port: self.data_plane_port,
expiry_time: self.expiry_time,
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for AuthorizeTargetsResponseView<'a> {
#[allow(clippy::needless_borrow, clippy::let_and_return)]
fn compute_size(&self, _cache: &mut ::buffa::SizeCache) -> u32 {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
let mut size = 0u32;
if !self.client_ip.is_empty() {
size += 1u32 + ::buffa::types::string_encoded_len(&self.client_ip) as u32;
}
if !self.wap_id.is_empty() {
size += 1u32 + ::buffa::types::string_encoded_len(&self.wap_id) as u32;
}
if self.data_plane_port != 0u32 {
size
+= 1u32
+ ::buffa::types::uint32_encoded_len(self.data_plane_port) as u32;
}
if self.expiry_time != 0u64 {
size += 1u32 + ::buffa::types::uint64_encoded_len(self.expiry_time) as u32;
}
size
}
#[allow(clippy::needless_borrow)]
fn write_to(
&self,
_cache: &mut ::buffa::SizeCache,
buf: &mut impl ::buffa::bytes::BufMut,
) {
#[allow(unused_imports)]
use ::buffa::Enumeration as _;
if !self.client_ip.is_empty() {
::buffa::types::put_string_field(1u32, &self.client_ip, buf);
}
if !self.wap_id.is_empty() {
::buffa::types::put_string_field(2u32, &self.wap_id, buf);
}
if self.data_plane_port != 0u32 {
::buffa::types::put_uint32_field(3u32, self.data_plane_port, buf);
}
if self.expiry_time != 0u64 {
::buffa::types::put_uint64_field(4u32, self.expiry_time, buf);
}
}
}
impl<'__a> ::serde::Serialize for AuthorizeTargetsResponseView<'__a> {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
use ::serde::ser::SerializeMap as _;
let mut __map = __s.serialize_map(::core::option::Option::None)?;
if !::buffa::json_helpers::skip_if::is_empty_str(self.client_ip) {
__map.serialize_entry("clientIp", self.client_ip)?;
}
if !::buffa::json_helpers::skip_if::is_empty_str(self.wap_id) {
__map.serialize_entry("wapId", self.wap_id)?;
}
if !::buffa::json_helpers::skip_if::is_zero_u32(&self.data_plane_port) {
__map
.serialize_entry(
"dataPlanePort",
&::buffa::json_helpers::ProtoJson(&self.data_plane_port),
)?;
}
if !::buffa::json_helpers::skip_if::is_zero_u64(&self.expiry_time) {
__map
.serialize_entry(
"expiryTime",
&::buffa::json_helpers::ProtoJson(&self.expiry_time),
)?;
}
__map.end()
}
}
impl<'a> ::buffa::MessageName for AuthorizeTargetsResponseView<'a> {
const PACKAGE: &'static str = "anapaya.wap.v1";
const NAME: &'static str = "AuthorizeTargetsResponse";
const FULL_NAME: &'static str = "anapaya.wap.v1.AuthorizeTargetsResponse";
const TYPE_URL: &'static str = "type.googleapis.com/anapaya.wap.v1.AuthorizeTargetsResponse";
}
::buffa::impl_default_view_instance!(AuthorizeTargetsResponseView);
::buffa::impl_view_reborrow!(AuthorizeTargetsResponseView);
#[derive(Clone, Debug)]
pub struct AuthorizeTargetsResponseOwnedView(
::buffa::OwnedView<AuthorizeTargetsResponseView<'static>>,
);
impl AuthorizeTargetsResponseOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
AuthorizeTargetsResponseOwnedView(::buffa::OwnedView::decode(bytes)?),
)
}
pub fn decode_with_options(
bytes: ::buffa::bytes::Bytes,
opts: &::buffa::DecodeOptions,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
AuthorizeTargetsResponseOwnedView(
::buffa::OwnedView::decode_with_options(bytes, opts)?,
),
)
}
pub fn from_owned(
msg: &super::super::AuthorizeTargetsResponse,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
AuthorizeTargetsResponseOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &AuthorizeTargetsResponseView<'_> {
self.0.reborrow()
}
pub fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::AuthorizeTargetsResponse,
::buffa::DecodeError,
> {
self.0.to_owned_message()
}
#[must_use]
pub fn bytes(&self) -> &::buffa::bytes::Bytes {
self.0.bytes()
}
#[must_use]
pub fn into_bytes(self) -> ::buffa::bytes::Bytes {
self.0.into_bytes()
}
#[must_use]
pub fn client_ip(&self) -> &'_ str {
self.0.reborrow().client_ip
}
#[must_use]
pub fn wap_id(&self) -> &'_ str {
self.0.reborrow().wap_id
}
#[must_use]
pub fn data_plane_port(&self) -> u32 {
self.0.reborrow().data_plane_port
}
#[must_use]
pub fn expiry_time(&self) -> u64 {
self.0.reborrow().expiry_time
}
}
impl ::core::convert::From<::buffa::OwnedView<AuthorizeTargetsResponseView<'static>>>
for AuthorizeTargetsResponseOwnedView {
fn from(inner: ::buffa::OwnedView<AuthorizeTargetsResponseView<'static>>) -> Self {
AuthorizeTargetsResponseOwnedView(inner)
}
}
impl ::core::convert::From<AuthorizeTargetsResponseOwnedView>
for ::buffa::OwnedView<AuthorizeTargetsResponseView<'static>> {
fn from(wrapper: AuthorizeTargetsResponseOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<::buffa::OwnedView<AuthorizeTargetsResponseView<'static>>>
for AuthorizeTargetsResponseOwnedView {
fn as_ref(&self) -> &::buffa::OwnedView<AuthorizeTargetsResponseView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::AuthorizeTargetsResponse {
type View<'a> = AuthorizeTargetsResponseView<'a>;
type ViewHandle = AuthorizeTargetsResponseOwnedView;
}
impl ::serde::Serialize for AuthorizeTargetsResponseOwnedView {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
::serde::Serialize::serialize(&self.0, __s)
}
}