Make the /resolve_magnet HTTP endpoint return an actual torrent file, not info

This commit is contained in:
Igor Katson 2024-08-13 19:06:17 +01:00
parent cd0f38f0fb
commit d54b67d2dc
No known key found for this signature in database
GPG key ID: B4EC22B66D61A3F5
6 changed files with 132 additions and 23 deletions

View file

@ -0,0 +1,28 @@
use serde::Serialize;
pub struct RawValue<T>(pub T);
pub(crate) const TAG: &str = "::librqbit_bencode::RawValue";
impl<T> Serialize for RawValue<T>
where
T: AsRef<[u8]>,
{
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
struct Wrapper<'a>(&'a [u8]);
impl<'a> Serialize for Wrapper<'a> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
serializer.serialize_bytes(self.0)
}
}
serializer.serialize_newtype_struct(TAG, &Wrapper(self.0.as_ref()))
}
}