#[derive(Clone, Debug, Default)]
pub struct GetSnapDataPlaneAddressRequestView<'a> {
#[doc(hidden)]
pub __buffa_phantom: ::core::marker::PhantomData<&'a ()>,
}
impl<'a> ::buffa::MessageView<'a> for GetSnapDataPlaneAddressRequestView<'a> {
type Owned = super::super::GetSnapDataPlaneAddressRequest;
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() {
_ => {
::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::GetSnapDataPlaneAddressRequest,
::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::GetSnapDataPlaneAddressRequest,
::buffa::DecodeError,
> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::GetSnapDataPlaneAddressRequest {
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for GetSnapDataPlaneAddressRequestView<'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 size = 0u32;
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 _;
}
}
impl<'__a> ::serde::Serialize for GetSnapDataPlaneAddressRequestView<'__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)?;
__map.end()
}
}
impl<'a> ::buffa::MessageName for GetSnapDataPlaneAddressRequestView<'a> {
const PACKAGE: &'static str = "anapaya.snap.v1";
const NAME: &'static str = "GetSnapDataPlaneAddressRequest";
const FULL_NAME: &'static str = "anapaya.snap.v1.GetSnapDataPlaneAddressRequest";
const TYPE_URL: &'static str = "type.googleapis.com/anapaya.snap.v1.GetSnapDataPlaneAddressRequest";
}
::buffa::impl_default_view_instance!(GetSnapDataPlaneAddressRequestView);
::buffa::impl_view_reborrow!(GetSnapDataPlaneAddressRequestView);
#[derive(Clone, Debug)]
pub struct GetSnapDataPlaneAddressRequestOwnedView(
::buffa::OwnedView<GetSnapDataPlaneAddressRequestView<'static>>,
);
impl GetSnapDataPlaneAddressRequestOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
GetSnapDataPlaneAddressRequestOwnedView(::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(
GetSnapDataPlaneAddressRequestOwnedView(
::buffa::OwnedView::decode_with_options(bytes, opts)?,
),
)
}
pub fn from_owned(
msg: &super::super::GetSnapDataPlaneAddressRequest,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
GetSnapDataPlaneAddressRequestOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &GetSnapDataPlaneAddressRequestView<'_> {
self.0.reborrow()
}
pub fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::GetSnapDataPlaneAddressRequest,
::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()
}
}
impl ::core::convert::From<
::buffa::OwnedView<GetSnapDataPlaneAddressRequestView<'static>>,
> for GetSnapDataPlaneAddressRequestOwnedView {
fn from(
inner: ::buffa::OwnedView<GetSnapDataPlaneAddressRequestView<'static>>,
) -> Self {
GetSnapDataPlaneAddressRequestOwnedView(inner)
}
}
impl ::core::convert::From<GetSnapDataPlaneAddressRequestOwnedView>
for ::buffa::OwnedView<GetSnapDataPlaneAddressRequestView<'static>> {
fn from(wrapper: GetSnapDataPlaneAddressRequestOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<
::buffa::OwnedView<GetSnapDataPlaneAddressRequestView<'static>>,
> for GetSnapDataPlaneAddressRequestOwnedView {
fn as_ref(
&self,
) -> &::buffa::OwnedView<GetSnapDataPlaneAddressRequestView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::GetSnapDataPlaneAddressRequest {
type View<'a> = GetSnapDataPlaneAddressRequestView<'a>;
type ViewHandle = GetSnapDataPlaneAddressRequestOwnedView;
}
impl ::serde::Serialize for GetSnapDataPlaneAddressRequestOwnedView {
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 GetSnapDataPlaneAddressResponseView<'a> {
pub address: &'a str,
pub snap_tun_control_address: ::core::option::Option<&'a str>,
pub snap_static_x25519: ::core::option::Option<&'a [u8]>,
}
impl<'a> ::buffa::MessageView<'a> for GetSnapDataPlaneAddressResponseView<'a> {
type Owned = super::super::GetSnapDataPlaneAddressResponse;
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.address = ::buffa::types::borrow_str(&mut cur)?;
}
2u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.snap_tun_control_address = Some(
::buffa::types::borrow_str(&mut cur)?,
);
}
3u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.snap_static_x25519 = Some(::buffa::types::borrow_bytes(&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::GetSnapDataPlaneAddressResponse,
::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::GetSnapDataPlaneAddressResponse,
::buffa::DecodeError,
> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::GetSnapDataPlaneAddressResponse {
address: self.address.to_string(),
snap_tun_control_address: self
.snap_tun_control_address
.map(|s| s.to_string()),
snap_static_x25519: self.snap_static_x25519.map(|b| (b).to_vec()),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for GetSnapDataPlaneAddressResponseView<'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.address.is_empty() {
size += 1u32 + ::buffa::types::string_encoded_len(&self.address) as u32;
}
if let Some(ref v) = self.snap_tun_control_address {
size += 1u32 + ::buffa::types::string_encoded_len(v) as u32;
}
if let Some(ref v) = self.snap_static_x25519 {
size += 1u32 + ::buffa::types::bytes_encoded_len(v) 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.address.is_empty() {
::buffa::types::put_string_field(1u32, &self.address, buf);
}
if let Some(ref v) = self.snap_tun_control_address {
::buffa::types::put_string_field(2u32, v, buf);
}
if let Some(ref v) = self.snap_static_x25519 {
::buffa::types::put_bytes_field(3u32, v, buf);
}
}
}
impl<'__a> ::serde::Serialize for GetSnapDataPlaneAddressResponseView<'__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.address) {
__map.serialize_entry("address", self.address)?;
}
if let ::core::option::Option::Some(__v) = self.snap_tun_control_address {
__map.serialize_entry("snapTunControlAddress", __v)?;
}
if let ::core::option::Option::Some(__v) = self.snap_static_x25519 {
__map
.serialize_entry(
"snapStaticX25519",
&::buffa::json_helpers::BytesJson(__v),
)?;
}
__map.end()
}
}
impl<'a> ::buffa::MessageName for GetSnapDataPlaneAddressResponseView<'a> {
const PACKAGE: &'static str = "anapaya.snap.v1";
const NAME: &'static str = "GetSnapDataPlaneAddressResponse";
const FULL_NAME: &'static str = "anapaya.snap.v1.GetSnapDataPlaneAddressResponse";
const TYPE_URL: &'static str = "type.googleapis.com/anapaya.snap.v1.GetSnapDataPlaneAddressResponse";
}
::buffa::impl_default_view_instance!(GetSnapDataPlaneAddressResponseView);
::buffa::impl_view_reborrow!(GetSnapDataPlaneAddressResponseView);
#[derive(Clone, Debug)]
pub struct GetSnapDataPlaneAddressResponseOwnedView(
::buffa::OwnedView<GetSnapDataPlaneAddressResponseView<'static>>,
);
impl GetSnapDataPlaneAddressResponseOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
GetSnapDataPlaneAddressResponseOwnedView(::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(
GetSnapDataPlaneAddressResponseOwnedView(
::buffa::OwnedView::decode_with_options(bytes, opts)?,
),
)
}
pub fn from_owned(
msg: &super::super::GetSnapDataPlaneAddressResponse,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
GetSnapDataPlaneAddressResponseOwnedView(
::buffa::OwnedView::from_owned(msg)?,
),
)
}
#[must_use]
pub fn view(&self) -> &GetSnapDataPlaneAddressResponseView<'_> {
self.0.reborrow()
}
pub fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::GetSnapDataPlaneAddressResponse,
::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 address(&self) -> &'_ str {
self.0.reborrow().address
}
#[must_use]
pub fn snap_tun_control_address(&self) -> ::core::option::Option<&'_ str> {
self.0.reborrow().snap_tun_control_address
}
#[must_use]
pub fn snap_static_x25519(&self) -> ::core::option::Option<&'_ [u8]> {
self.0.reborrow().snap_static_x25519
}
}
impl ::core::convert::From<
::buffa::OwnedView<GetSnapDataPlaneAddressResponseView<'static>>,
> for GetSnapDataPlaneAddressResponseOwnedView {
fn from(
inner: ::buffa::OwnedView<GetSnapDataPlaneAddressResponseView<'static>>,
) -> Self {
GetSnapDataPlaneAddressResponseOwnedView(inner)
}
}
impl ::core::convert::From<GetSnapDataPlaneAddressResponseOwnedView>
for ::buffa::OwnedView<GetSnapDataPlaneAddressResponseView<'static>> {
fn from(wrapper: GetSnapDataPlaneAddressResponseOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<
::buffa::OwnedView<GetSnapDataPlaneAddressResponseView<'static>>,
> for GetSnapDataPlaneAddressResponseOwnedView {
fn as_ref(
&self,
) -> &::buffa::OwnedView<GetSnapDataPlaneAddressResponseView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::GetSnapDataPlaneAddressResponse {
type View<'a> = GetSnapDataPlaneAddressResponseView<'a>;
type ViewHandle = GetSnapDataPlaneAddressResponseOwnedView;
}
impl ::serde::Serialize for GetSnapDataPlaneAddressResponseOwnedView {
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 RegisterSnapTunIdentityRequestView<'a> {
pub initiator_static_x25519: &'a [u8],
pub psk_share: &'a [u8],
}
impl<'a> ::buffa::MessageView<'a> for RegisterSnapTunIdentityRequestView<'a> {
type Owned = super::super::RegisterSnapTunIdentityRequest;
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.initiator_static_x25519 = ::buffa::types::borrow_bytes(&mut cur)?;
}
2u32 => {
::buffa::encoding::check_wire_type(
tag,
::buffa::encoding::WireType::LengthDelimited,
)?;
view.psk_share = ::buffa::types::borrow_bytes(&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::RegisterSnapTunIdentityRequest,
::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::RegisterSnapTunIdentityRequest,
::buffa::DecodeError,
> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::RegisterSnapTunIdentityRequest {
initiator_static_x25519: (self.initiator_static_x25519).to_vec(),
psk_share: (self.psk_share).to_vec(),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for RegisterSnapTunIdentityRequestView<'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.initiator_static_x25519.is_empty() {
size
+= 1u32
+ ::buffa::types::bytes_encoded_len(&self.initiator_static_x25519)
as u32;
}
if !self.psk_share.is_empty() {
size += 1u32 + ::buffa::types::bytes_encoded_len(&self.psk_share) 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.initiator_static_x25519.is_empty() {
::buffa::types::put_bytes_field(1u32, &self.initiator_static_x25519, buf);
}
if !self.psk_share.is_empty() {
::buffa::types::put_bytes_field(2u32, &self.psk_share, buf);
}
}
}
impl<'__a> ::serde::Serialize for RegisterSnapTunIdentityRequestView<'__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_bytes(
self.initiator_static_x25519,
) {
__map
.serialize_entry(
"initiatorStaticX25519",
&::buffa::json_helpers::BytesJson(self.initiator_static_x25519),
)?;
}
if !::buffa::json_helpers::skip_if::is_empty_bytes(self.psk_share) {
__map
.serialize_entry(
"pskShare",
&::buffa::json_helpers::BytesJson(self.psk_share),
)?;
}
__map.end()
}
}
impl<'a> ::buffa::MessageName for RegisterSnapTunIdentityRequestView<'a> {
const PACKAGE: &'static str = "anapaya.snap.v1";
const NAME: &'static str = "RegisterSnapTunIdentityRequest";
const FULL_NAME: &'static str = "anapaya.snap.v1.RegisterSnapTunIdentityRequest";
const TYPE_URL: &'static str = "type.googleapis.com/anapaya.snap.v1.RegisterSnapTunIdentityRequest";
}
::buffa::impl_default_view_instance!(RegisterSnapTunIdentityRequestView);
::buffa::impl_view_reborrow!(RegisterSnapTunIdentityRequestView);
#[derive(Clone, Debug)]
pub struct RegisterSnapTunIdentityRequestOwnedView(
::buffa::OwnedView<RegisterSnapTunIdentityRequestView<'static>>,
);
impl RegisterSnapTunIdentityRequestOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
RegisterSnapTunIdentityRequestOwnedView(::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(
RegisterSnapTunIdentityRequestOwnedView(
::buffa::OwnedView::decode_with_options(bytes, opts)?,
),
)
}
pub fn from_owned(
msg: &super::super::RegisterSnapTunIdentityRequest,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
RegisterSnapTunIdentityRequestOwnedView(::buffa::OwnedView::from_owned(msg)?),
)
}
#[must_use]
pub fn view(&self) -> &RegisterSnapTunIdentityRequestView<'_> {
self.0.reborrow()
}
pub fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::RegisterSnapTunIdentityRequest,
::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 initiator_static_x25519(&self) -> &'_ [u8] {
self.0.reborrow().initiator_static_x25519
}
#[must_use]
pub fn psk_share(&self) -> &'_ [u8] {
self.0.reborrow().psk_share
}
}
impl ::core::convert::From<
::buffa::OwnedView<RegisterSnapTunIdentityRequestView<'static>>,
> for RegisterSnapTunIdentityRequestOwnedView {
fn from(
inner: ::buffa::OwnedView<RegisterSnapTunIdentityRequestView<'static>>,
) -> Self {
RegisterSnapTunIdentityRequestOwnedView(inner)
}
}
impl ::core::convert::From<RegisterSnapTunIdentityRequestOwnedView>
for ::buffa::OwnedView<RegisterSnapTunIdentityRequestView<'static>> {
fn from(wrapper: RegisterSnapTunIdentityRequestOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<
::buffa::OwnedView<RegisterSnapTunIdentityRequestView<'static>>,
> for RegisterSnapTunIdentityRequestOwnedView {
fn as_ref(
&self,
) -> &::buffa::OwnedView<RegisterSnapTunIdentityRequestView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::RegisterSnapTunIdentityRequest {
type View<'a> = RegisterSnapTunIdentityRequestView<'a>;
type ViewHandle = RegisterSnapTunIdentityRequestOwnedView;
}
impl ::serde::Serialize for RegisterSnapTunIdentityRequestOwnedView {
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 RegisterSnapTunIdentityResponseView<'a> {
pub psk_share: &'a [u8],
}
impl<'a> ::buffa::MessageView<'a> for RegisterSnapTunIdentityResponseView<'a> {
type Owned = super::super::RegisterSnapTunIdentityResponse;
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.psk_share = ::buffa::types::borrow_bytes(&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::RegisterSnapTunIdentityResponse,
::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::RegisterSnapTunIdentityResponse,
::buffa::DecodeError,
> {
#[allow(unused_imports)]
use ::buffa::alloc::string::ToString as _;
let _ = __buffa_src;
::core::result::Result::Ok(super::super::RegisterSnapTunIdentityResponse {
psk_share: (self.psk_share).to_vec(),
..::core::default::Default::default()
})
}
}
impl<'a> ::buffa::ViewEncode<'a> for RegisterSnapTunIdentityResponseView<'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.psk_share.is_empty() {
size += 1u32 + ::buffa::types::bytes_encoded_len(&self.psk_share) 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.psk_share.is_empty() {
::buffa::types::put_bytes_field(1u32, &self.psk_share, buf);
}
}
}
impl<'__a> ::serde::Serialize for RegisterSnapTunIdentityResponseView<'__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_bytes(self.psk_share) {
__map
.serialize_entry(
"pskShare",
&::buffa::json_helpers::BytesJson(self.psk_share),
)?;
}
__map.end()
}
}
impl<'a> ::buffa::MessageName for RegisterSnapTunIdentityResponseView<'a> {
const PACKAGE: &'static str = "anapaya.snap.v1";
const NAME: &'static str = "RegisterSnapTunIdentityResponse";
const FULL_NAME: &'static str = "anapaya.snap.v1.RegisterSnapTunIdentityResponse";
const TYPE_URL: &'static str = "type.googleapis.com/anapaya.snap.v1.RegisterSnapTunIdentityResponse";
}
::buffa::impl_default_view_instance!(RegisterSnapTunIdentityResponseView);
::buffa::impl_view_reborrow!(RegisterSnapTunIdentityResponseView);
#[derive(Clone, Debug)]
pub struct RegisterSnapTunIdentityResponseOwnedView(
::buffa::OwnedView<RegisterSnapTunIdentityResponseView<'static>>,
);
impl RegisterSnapTunIdentityResponseOwnedView {
pub fn decode(
bytes: ::buffa::bytes::Bytes,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
RegisterSnapTunIdentityResponseOwnedView(::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(
RegisterSnapTunIdentityResponseOwnedView(
::buffa::OwnedView::decode_with_options(bytes, opts)?,
),
)
}
pub fn from_owned(
msg: &super::super::RegisterSnapTunIdentityResponse,
) -> ::core::result::Result<Self, ::buffa::DecodeError> {
::core::result::Result::Ok(
RegisterSnapTunIdentityResponseOwnedView(
::buffa::OwnedView::from_owned(msg)?,
),
)
}
#[must_use]
pub fn view(&self) -> &RegisterSnapTunIdentityResponseView<'_> {
self.0.reborrow()
}
pub fn to_owned_message(
&self,
) -> ::core::result::Result<
super::super::RegisterSnapTunIdentityResponse,
::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 psk_share(&self) -> &'_ [u8] {
self.0.reborrow().psk_share
}
}
impl ::core::convert::From<
::buffa::OwnedView<RegisterSnapTunIdentityResponseView<'static>>,
> for RegisterSnapTunIdentityResponseOwnedView {
fn from(
inner: ::buffa::OwnedView<RegisterSnapTunIdentityResponseView<'static>>,
) -> Self {
RegisterSnapTunIdentityResponseOwnedView(inner)
}
}
impl ::core::convert::From<RegisterSnapTunIdentityResponseOwnedView>
for ::buffa::OwnedView<RegisterSnapTunIdentityResponseView<'static>> {
fn from(wrapper: RegisterSnapTunIdentityResponseOwnedView) -> Self {
wrapper.0
}
}
impl ::core::convert::AsRef<
::buffa::OwnedView<RegisterSnapTunIdentityResponseView<'static>>,
> for RegisterSnapTunIdentityResponseOwnedView {
fn as_ref(
&self,
) -> &::buffa::OwnedView<RegisterSnapTunIdentityResponseView<'static>> {
&self.0
}
}
impl ::buffa::HasMessageView for super::super::RegisterSnapTunIdentityResponse {
type View<'a> = RegisterSnapTunIdentityResponseView<'a>;
type ViewHandle = RegisterSnapTunIdentityResponseOwnedView;
}
impl ::serde::Serialize for RegisterSnapTunIdentityResponseOwnedView {
fn serialize<__S: ::serde::Serializer>(
&self,
__s: __S,
) -> ::core::result::Result<__S::Ok, __S::Error> {
::serde::Serialize::serialize(&self.0, __s)
}
}