Add explicit lifetime for SerializationOptions

This commit is contained in:
2026-07-07 21:13:36 -04:00
parent e98da77871
commit 2367de77ca
+6 -6
View File
@@ -100,12 +100,12 @@ impl<D> RdfSource<D> {
}
/// Holds options related to serialization.
pub struct SerializationOptions {
pub struct SerializationOptions<'a> {
format: RdfFormat,
filter: Box<dyn Fn(TripleRef<'_>) -> bool>,
filter: Box<dyn Fn(TripleRef<'a>) -> bool>,
}
impl SerializationOptions {
impl<'a> SerializationOptions<'a> {
/// Create a new set of serialization options with the provided format.
pub fn from_format(format: RdfFormat) -> Self {
Self {
@@ -120,7 +120,7 @@ impl SerializationOptions {
#[must_use]
pub fn with_filter<F>(self, filter: F) -> Self
where
F: Fn(TripleRef<'_>) -> bool + 'static,
F: Fn(TripleRef<'a>) -> bool + 'static,
{
Self {
format: self.format,
@@ -134,7 +134,7 @@ where
&'a D: IntoIterator<Item = QuadRef<'a>>,
{
/// Serializes the dataset in to the provided format.
pub fn serialize(&'a self, options: SerializationOptions) -> crate::Result<bytes::Bytes> {
pub fn serialize(&'a self, options: SerializationOptions<'a>) -> crate::Result<bytes::Bytes> {
let writer = bytes::BytesMut::new().writer();
let mut serializer = RdfSerializer::from_format(options.format).for_writer(writer);
@@ -159,7 +159,7 @@ where
/// Prepare an update request.
pub fn to_update(
&'a self,
options: SerializationOptions,
options: SerializationOptions<'a>,
) -> crate::Result<RdfSourceUpdateRequest> {
let url = self.described_by.clone().unwrap_or(self.origin.clone());
let media_type = options.format.media_type().to_string();