Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consistently use Error::NotAvailable instead of Unsupported #349

Merged
merged 2 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions lib/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ impl Error {
Error::BufferLengthError { .. } => FastlyStatus::Buflen,
Error::InvalidArgument => FastlyStatus::Inval,
Error::ValueAbsent => FastlyStatus::None,
Error::Unsupported { .. } => FastlyStatus::Unsupported,
Error::Unsupported { .. } | Error::NotAvailable(_) => FastlyStatus::Unsupported,
Error::HandleError { .. } => FastlyStatus::Badf,
Error::InvalidStatusCode { .. } => FastlyStatus::Inval,
Error::UnknownBackend(_) | Error::InvalidClientCert(_) => FastlyStatus::Inval,
Expand Down Expand Up @@ -199,7 +199,6 @@ impl Error {
| Error::InvalidMethod(_)
| Error::InvalidUri(_)
| Error::IoError(_)
| Error::NotAvailable(_)
| Error::Other(_)
| Error::ProfilingStrategy
| Error::StreamingChunkSend
Expand Down
20 changes: 5 additions & 15 deletions lib/src/wiggle_abi/backend_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,7 @@ impl FastlyBackend for Session {
// just doing this to get a different error if the backend doesn't exist
let _ = lookup_backend_definition(self, backend)?;
// health checks are not enabled in Viceroy :(
Err(Error::Unsupported {
msg: "connection timing is not actually supported in Viceroy",
})
Err(Error::NotAvailable("Connection timing"))
}

fn get_first_byte_timeout_ms(
Expand All @@ -155,9 +153,7 @@ impl FastlyBackend for Session {
// just doing this to get a different error if the backend doesn't exist
let _ = lookup_backend_definition(self, backend)?;
// health checks are not enabled in Viceroy :(
Err(Error::Unsupported {
msg: "connection timing is not actually supported in Viceroy",
})
Err(Error::NotAvailable("Connection timing"))
}

fn get_between_bytes_timeout_ms(
Expand All @@ -167,9 +163,7 @@ impl FastlyBackend for Session {
// just doing this to get a different error if the backend doesn't exist
let _ = lookup_backend_definition(self, backend)?;
// health checks are not enabled in Viceroy :(
Err(Error::Unsupported {
msg: "connection timing is not actually supported in Viceroy",
})
Err(Error::NotAvailable("Connection timing"))
}

fn get_ssl_min_version(
Expand All @@ -179,9 +173,7 @@ impl FastlyBackend for Session {
// just doing this to get a different error if the backend doesn't exist
let _ = lookup_backend_definition(self, backend)?;
// health checks are not enabled in Viceroy :(
Err(Error::Unsupported {
msg: "ssl version flags are not supported in Viceroy",
})
Err(Error::NotAvailable("SSL version information"))
}

fn get_ssl_max_version(
Expand All @@ -191,9 +183,7 @@ impl FastlyBackend for Session {
// just doing this to get a different error if the backend doesn't exist
let _ = lookup_backend_definition(self, backend)?;
// health checks are not enabled in Viceroy :(
Err(Error::Unsupported {
msg: "ssl version flags are not supported in Viceroy",
})
Err(Error::NotAvailable("SSL version information"))
}

fn is_ssl(&mut self, backend: &wiggle::GuestPtr<str>) -> Result<super::types::IsSsl, Error> {
Expand Down
64 changes: 16 additions & 48 deletions lib/src/wiggle_abi/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ impl FastlyCache for Session {
options_mask: types::CacheLookupOptionsMask,
options: &wiggle::GuestPtr<'a, types::CacheLookupOptions>,
) -> Result<types::CacheHandle, Error> {
Err(Error::Unsupported {
msg: "Cache API primitives not yet supported",
})
Err(Error::NotAvailable("Cache API primitives"))
}

fn insert<'a>(
Expand All @@ -22,9 +20,7 @@ impl FastlyCache for Session {
options_mask: types::CacheWriteOptionsMask,
options: &wiggle::GuestPtr<'a, types::CacheWriteOptions<'a>>,
) -> Result<types::BodyHandle, Error> {
Err(Error::Unsupported {
msg: "Cache API primitives not yet supported",
})
Err(Error::NotAvailable("Cache API primitives"))
}

fn transaction_lookup<'a>(
Expand All @@ -33,9 +29,7 @@ impl FastlyCache for Session {
options_mask: types::CacheLookupOptionsMask,
options: &wiggle::GuestPtr<'a, types::CacheLookupOptions>,
) -> Result<types::CacheHandle, Error> {
Err(Error::Unsupported {
msg: "Cache API primitives not yet supported",
})
Err(Error::NotAvailable("Cache API primitives"))
}

fn transaction_insert<'a>(
Expand All @@ -44,9 +38,7 @@ impl FastlyCache for Session {
options_mask: types::CacheWriteOptionsMask,
options: &wiggle::GuestPtr<'a, types::CacheWriteOptions<'a>>,
) -> Result<types::BodyHandle, Error> {
Err(Error::Unsupported {
msg: "Cache API primitives not yet supported",
})
Err(Error::NotAvailable("Cache API primitives"))
}

fn transaction_insert_and_stream_back<'a>(
Expand All @@ -55,9 +47,7 @@ impl FastlyCache for Session {
options_mask: types::CacheWriteOptionsMask,
options: &wiggle::GuestPtr<'a, types::CacheWriteOptions<'a>>,
) -> Result<(types::BodyHandle, types::CacheHandle), Error> {
Err(Error::Unsupported {
msg: "Cache API primitives not yet supported",
})
Err(Error::NotAvailable("Cache API primitives"))
}

fn transaction_update<'a>(
Expand All @@ -66,27 +56,19 @@ impl FastlyCache for Session {
options_mask: types::CacheWriteOptionsMask,
options: &wiggle::GuestPtr<'a, types::CacheWriteOptions<'a>>,
) -> Result<(), Error> {
Err(Error::Unsupported {
msg: "Cache API primitives not yet supported",
})
Err(Error::NotAvailable("Cache API primitives"))
}

fn transaction_cancel(&mut self, handle: types::CacheHandle) -> Result<(), Error> {
Err(Error::Unsupported {
msg: "Cache API primitives not yet supported",
})
Err(Error::NotAvailable("Cache API primitives"))
}

fn close(&mut self, handle: types::CacheHandle) -> Result<(), Error> {
Err(Error::Unsupported {
msg: "Cache API primitives not yet supported",
})
Err(Error::NotAvailable("Cache API primitives"))
}

fn get_state(&mut self, handle: types::CacheHandle) -> Result<types::CacheLookupState, Error> {
Err(Error::Unsupported {
msg: "Cache API primitives not yet supported",
})
Err(Error::NotAvailable("Cache API primitives"))
}

fn get_user_metadata<'a>(
Expand All @@ -96,9 +78,7 @@ impl FastlyCache for Session {
user_metadata_out_len: u32,
nwritten_out: &wiggle::GuestPtr<'a, u32>,
) -> Result<(), Error> {
Err(Error::Unsupported {
msg: "Cache API primitives not yet supported",
})
Err(Error::NotAvailable("Cache API primitives"))
}

fn get_body(
Expand All @@ -107,47 +87,35 @@ impl FastlyCache for Session {
options_mask: types::CacheGetBodyOptionsMask,
options: &types::CacheGetBodyOptions,
) -> Result<types::BodyHandle, Error> {
Err(Error::Unsupported {
msg: "Cache API primitives not yet supported",
})
Err(Error::NotAvailable("Cache API primitives"))
}

fn get_length(
&mut self,
handle: types::CacheHandle,
) -> Result<types::CacheObjectLength, Error> {
Err(Error::Unsupported {
msg: "Cache API primitives not yet supported",
})
Err(Error::NotAvailable("Cache API primitives"))
}

fn get_max_age_ns(
&mut self,
handle: types::CacheHandle,
) -> Result<types::CacheDurationNs, Error> {
Err(Error::Unsupported {
msg: "Cache API primitives not yet supported",
})
Err(Error::NotAvailable("Cache API primitives"))
}

fn get_stale_while_revalidate_ns(
&mut self,
handle: types::CacheHandle,
) -> Result<types::CacheDurationNs, Error> {
Err(Error::Unsupported {
msg: "Cache API primitives not yet supported",
})
Err(Error::NotAvailable("Cache API primitives"))
}

fn get_age_ns(&mut self, handle: types::CacheHandle) -> Result<types::CacheDurationNs, Error> {
Err(Error::Unsupported {
msg: "Cache API primitives not yet supported",
})
Err(Error::NotAvailable("Cache API primitives"))
}

fn get_hits(&mut self, handle: types::CacheHandle) -> Result<types::CacheHitCount, Error> {
Err(Error::Unsupported {
msg: "Cache API primitives not yet supported",
})
Err(Error::NotAvailable("Cache API primitives"))
}
}
Loading