I'm translating this C# code
#region Prefix
private const string FilePrefix = @"file://";
private const string HttpPrefix = @"http://";
private const string Base64Prefix = @"base64://";
#endregion
public static async Task<Stream> GetAssetFile(string url)
{
if (url.StartsWith(FilePrefix))
{
url = url.Replace(FilePrefix, "");
return File.OpenRead(url);
}
if (url.StartsWith(HttpPrefix))
{
HttpWebRequest request = RequestHelper.CreateWebRequest(url);
return (await request.GetResponseAsync()).GetResponseStream();
}
if (url.StartsWith(Base64Prefix))
{
url = url.Replace(Base64Prefix, "");
byte[] bytes = Convert.FromBase64String(url);
return new MemoryStream(bytes, false);
}
throw new InvalidOperationException($"Invalid Url:{url}");
}
}
I want to translate this into Rust.But I don't know how to set the return value of the function.